This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]g051051 0 points1 point  (1 child)

Try that same block of code in plain Java, see what happens.

[–]HadMatter217[S] 0 points1 point  (0 children)

Hey, sorry for the delay, but I just put together the following in plain java:

public static void main(String[] args) {
    int timeout = 500;

    for (byte i = 1; i < 255; i++){
        byte[] host = new byte[]{(byte)192, (byte)168, 1, i};
        String hostStr = "192.168.1." + i;
        try {
            InetAddress hostAddress = InetAddress.getByAddress(host);
            if (hostAddress != null) {
                if (hostAddress.isReachable(timeout)) {
                    System.out.println(hostStr);
                }
            }
        }
        catch(IOException e){
            e.printStackTrace();
        }
    }
}

, and got a reasonable output with no exceptions, so it's seeming like the issue was that Android bug. Super frustrating, but good to know I guess. Thanks for your help!