package ping;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class PingExample {
public static void main(String[] args) throws UnknownHostException, IOException {
InetAddress inet;
inet = InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 });
System.out.println("Sending Ping Request to " + inet);
System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable" );
inet = InetAddress.getByAddress(new byte[] { (byte) 170, (byte) 0, 0, 1 });
System.out.println("Sending Ping Request to " + inet);
System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable" );
}
}
reponse --------------------------------->
Sending Ping Request to /127.0.0.1
Host is reachable
Sending Ping Request to /170.0.0.1
Host is reachable
question ---------> comment je peux ajouter une intervalle d'adress pour le ping svp