JAvaはIPがpingできるかどうかを判断する
793 ワード
boolean isIpReachable = false;
while (!isIpReachable)
{
InetAddress address;
try
{
address = InetAddress.getByName("172.17.22.4");
isIpReachable = address.isReachable(3000);
System.out.println("Name: " + address.getHostName());
System.out.println("Addr: " + address.getHostAddress());
System.out.println("isIpReachable: " + isIpReachable);
}
catch (UnknownHostException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
}
System.out.println("===================================");
}