InetAddress.isReachable()
What is the different between, isReachable(NetworkInterface netif, int ttl, int timeout) and isReachable(int timeout) ?
i tried with this..
InetAddress address = InetAddress.getByName("google.com");
System.out.println("Name: " + address.getHostName());
System.out.println("Addr: " + address.getHostAddress());
System.out.println("Reach: " + address.isReachable(3000));
System.out.println("Reach 2: " + address.isReachable(NetworkInterface.getByName("google.com"), 0, 100000));
and i get this
Name: google.com
Addr: 64.233.167.99
Reach: false
Reach 2: true
different people on the web actually give different ans.
and normally what is the standard timeout for isReachable?
Thanks in advanved.
[782 byte] By [
JieShenga] at [2007-11-26 21:59:57]

# 1
> System.out.println("Reach 2: " +
> address.isReachable(NetworkInterface.getByName("google
> .com"), 0, 100000));
This makes no sense. NetworkInterface.getByName() should be supplied with the name of one of your own IP addresses. This will be something like 'eth0'. I'm surprised that supplying the hostname of a foreign host worked at all.
ejpa at 2007-7-10 3:59:23 >

# 9
Interesting that you are talking about InetAddress.isReachable() as I am having an issue with it...
I have three machines. One server running Linux, one PC inside our firewall running XP and one PC outside our firewall running XP. The PC outside our network is connected through a VPN to our network.
I have a little java application running on both XP machines that check to see if the Linux box is reachable.
import java.io.*;
import java.net.*;
public class Reachable
{
public static void main(String args[])
{
while (true)
{
try
{
InetAddress address = InetAddress.getByName("rogtux.xyz.com");
System.out.println("Name: " + address.getHostName());
System.out.println("Addr: " + address.getHostAddress());
System.out.println("Reach: " + address.isReachable(3000));
}
catch (UnknownHostException e)
{
System.err.println("Unable to lookup rogtux.xyz.com");
}
catch (IOException e)
{
System.err.println("Unable to reach rogtux.xyz.com");
}
try
{
Thread.sleep(1000);
}
catch (Exception e)
{
}
}
}
}
The XP box that inside the firewall says that the Linux box IS reachable, but the XP box that is outside the firewall says that the Linux box IS NOT reachable.
We have checked our firewall and both XP boxes are getting through on port 7. The Linux box is getting the requests on port 7 also as I can see them using Ethereal.
Any ideas why InetAddress.isReachable() would be returning FALSE?
Much thanks.
-Jeff