Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   InetAddress isReachable() (http://www.velocityreviews.com/forums/t140906-inetaddress-isreachable.html)

andy.dreistadt@gmail.com 02-10-2005 03:07 PM

InetAddress isReachable()
 
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[i] = temp_addr.isReachable(2000);
System.out.println("isReachable[" + i + "]: " + isReachable[i]);
}
catch(IOException e)
{
JOptionPane.showConfirmDialog(null, "NetInterface " +
(String)Names.get(i) + " could not be found.", "Invalid IP",
JOptionPane.DEFAULT_OPTION);
}

if (!isReachable[i])
{
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



All times are GMT. The time now is 10:22 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.