你好,我只是想知道如何使用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请求。
有人可以帮我找出解决此问题的方法吗?