I am trying to find out if certain hosts are available on my network. My Java code is as follows:
InetAddress adr = InetAddress.getByName(host); if(adr.isReachable(3000)){ System.out.println(host + " is reachable"); }
This works pretty well, however, if I reduce the timeout to say 500 ms, it will no longer determine the availability of the node. I plan to test quite a few hosts in a loop, so having a low timeout is very important. If I ping the host manually from the Windows command prompt, it takes less than 10 ms.
So, why does the Java method require a much higher timeout? Are there alternatives to using isReachable() ?
java ping
Jerome
source share