Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > InetAddress isReachable()

Reply
Thread Tools

InetAddress isReachable()

 
 
andy.dreistadt@gmail.com
Guest
Posts: n/a
 
      02-10-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
InetAddress question Rhino Java 1 02-26-2005 04:52 PM
InetAddress Linus Java 5 01-31-2005 09:25 AM
performing reverse DNS lookup with InetAddress Madhur Ahuja Java 1 08-29-2004 07:57 AM
IP: long-> InetAddress vertigo Java 2 05-02-2004 11:59 PM
Solaris 9 and InetAddress with IP hostname C Java 1 09-16-2003 12:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57