I've made a small program to
test whether the current TCP/IP settings is good to establish an internet connection.
The working IP settings should be auto obtain (DHCP) IP. So Naturally the first HTTPURLConnection try block (line 17-24) should return 200, while the second one (line 28-35) should return 404. But somehow it still returns 200. I suspect that the IP is still in the middle of changing (the change is not complete yet) when the second try block runs. Any way to solve this?
And while we're at it, is there a way to set the timeout limit? because when connection cannot be established, the con.connect() takes quite a while before throwing an exception.
FYI, I've also tried InetAddress.getByName(host).isReachable(int TimeOut), but it always returns false eventhough i can access google.com in the browser.