I am trying to find out if specific hosts on my network are reachable. My java code is as follows:
InetAddress adr = InetAddress.getByName(host);
if(adr.isReachable(3000)){
System.out.println(host + " is reachable");
}
This works quite well, however if I lower the timeout to say 500ms instead, it will not designate the host reachable anymore. I plan to check quite a few hosts in a loop, so having a low timeout is quite important. If I ping the host manually from the windows command line, it takes less than 10ms.
So why does the Java method need a much higher timeout to succeed?
Are there any alternatives to using isReachable()
?