InetAddress isReachable()

A

andy.dreistadt

Hi all,

I was wondering if anyone has used the isReachable() method from the
InetAddress class and could help me with a problem I'm having. Here's
the situation:

I'm creating an InetAddress as shown below and checking to see if each
IP is reachable. Earlier I thought that this method was a kind of
"ping" and until now it has acted that way.

//Check to see if each device is connected
isReachable = new boolean[gtps.size()];
for (int i = 0; i < gtps.size(); i++)
{
InetAddress temp_addr = (InetAddress)IP_addresses.get(i);
try
{
isReachable = temp_addr.isReachable(2000);
System.out.println("isReachable[" + i + "]: " + isReachable);
}
catch(IOException e)
{
JOptionPane.showConfirmDialog(null, "NetInterface " +
(String)Names.get(i) + " could not be found.", "Invalid IP",
JOptionPane.DEFAULT_OPTION);
}

if (!isReachable)
{
removeIP(i);
}
}


When I run this code when the IP devices are connected, the isReachable
will return true. If they are disconnected, the value becomes false
(which is what made me believe this is some sort of ping function).
However, when I disconnect my computer from the network that the IP
values are on, isReachable will return true. Is there something
conceptually that I am missing about the method? I have considered the
fact that isReachable will return true if a device at that IP _could_
be reached even though it doesn't exist, but then disconnecting the
network should return false, right?

Any help in this matter would be greatly appreciated.

Thanks in advance,

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top