Java TCP Ping IP地址

时间:2019-11-16 19:25:48

标签: java tcp ping

你好,我只是想知道如何使用TCP协议ping IP地址。

我尝试过:

public static void sendPingRequest(String ipAddress) throws UnknownHostException, IOException { 
  InetAddress geek = InetAddress.getByName(ipAddress); 
  System.out.println("Sending Ping Request to " + ipAddress); 
  if (geek.isReachable(5000)) 
    System.out.println("Host is reachable"); 
  else
    System.out.println("Sorry ! We can't reach to this host"); 
}

但这不起作用,因为我的Internet服务提供商阻止了UDP请求。

有人可以帮我找出解决此问题的方法吗?

0 个答案:

没有答案