Java InetAddress .isReachable (NetworkInterface netif, int ttl, int timeout)
Syntax
InetAddress.isReachable(NetworkInterface netif, int ttl, int timeout) has the following syntax.
public boolean isReachable(NetworkInterface netif, int ttl, int timeout) throws IOException
Example
In the following code shows how to use InetAddress.isReachable(NetworkInterface netif, int ttl, int timeout) method.
import java.net.InetAddress;
import java.net.NetworkInterface;
//from w w w . ja v a 2 s. c om
public class Main {
public static void main(String[] argv) throws Exception {
InetAddress address = InetAddress.getByName("web.mit.edu");
System.out.println("Name: " + address.getHostName());
System.out.println("Addr: " + address.getHostAddress());
System.out.println("Reach: " + address.isReachable(NetworkInterface.getByIndex(0),0,3000));
}
}
The code above generates the following result.