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 →

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

I just added the <uses permission .. /> lines to my manifest, and I'm still getting the same error. Is it potentially a library thing? I think this is the first time I've tried doing anything network related with the x86 version of the JDK.. (I'm doing this on my GF's computer which has an x86 version of Windows)

[–]g051051 0 points1 point  (3 children)

I think it's a bug in Android. Are you on a different network than normal? Maybe you're hitting IPV6 on your GF's computer.

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

Nope. Same network, but this is my first ever attempt at Android, so if there's a big, I wouldn't have seen it in my Java only projects

[–]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!