Trying to run a loop to check if a IP is open.
for (int z = 0; z < 100; z++) {
String ip = "10.0.0." + z;
try {
log(ip);
Socket socket = new Socket(ip, MainActivity._util.getPort());
// Handle Stuff when Exception NOT throw
} catch (Exception e) {
}
}
log is a function I made (no errors there)
.getPort() is just a "global" port number I've defined EDIT : That returns 2683 (just a random number)
it is supposed to just catch the exception then move on with the for loop but that doesn't happen.
Currently this just prints:
10.0.0.0
10.0.0.1
and then freezes.
If anyone has any advice that would be great!
EDIT
using socket.connect(new InetSocketAddress(ip, port), timeout) method still didn't handle correctly
This is in an AsyncTask extended class, in the doInBackground() method