1
这里是我的代码:无法从应用ping主机,但不能以其他方式
InetAddress address =
InetAddress.getByName("www.whyoceans.com");
if (!address.isReachable(3000)) {
Toast.makeText(this,
"Unable to ping host",
Toast.LENGTH_SHORT).show();
}
的isReachable总是失败,但我可以打开一个shell和ping它只是 罚款(来自我的电脑和我的手机):
ping www.whyoceans.com
PING www.whyoceans.com (69.163.249.123) 56(84) bytes of data.
64 bytes from apache2-fritz.harmony.dreamhost.com (69.163.249.123):
icmp_seq=1 ttl=55 time=38.3 ms
64 bytes from apache2-fritz.harmony.dreamhost.com (69.163.249.123):
icmp_seq=2 ttl=55 time=40.9 ms
^C
--- www.whyoceans.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 38.319/39.654/40.989/1.335 ms
为什么?