Ping a host : Ping « Network Protocol « Java






Ping a host

 
 
import java.net.InetAddress;

public class Main {
  public static void main(String[] args) throws Exception {
    InetAddress address = InetAddress.getByName("17.16.15.14");

    boolean reachable = address.isReachable(10000);

    System.out.println("Is host reachable? " + reachable);
  }
}
 

   
  








Related examples in the same category

1.java.net.InetAddress.isReachable(int) can be used to check if a server is reachable or not.