Tim Moores wrote: Try opening a TCP connection to them first.
How? What is the java code?
Test whether that address is reachable. Best effort is made by the implementation to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible. A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.
TCP echo will not enabled by many of the devices that you may probe. It needs to be explictly be installed as a service in Windows, and configured on in Linux. You could try running ping with something like this. but it would be very slow for your application if kept single-threaded - Windows seems to have a minimum timeout of 1 second:
Tim Moores wrote:
Richie Davies wrote:Why is not there a faster way to ping many hosts in java?
Somebody probably has written one, but not open-sourced it. You could fill that gap by writing code that accesses multiple hosts in parallel, and making it available to the general public.
Can you help me to do it together?
A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.
The actual implementation in the JDK is C code, though, which I didn't feel like delving into :-)
The reasons why those fail on localhost and the router need not be the same (and probably aren't), but you could try telnet-ing to port 7 of both hosts and see what happens, and also ping them manually.