这是我的密码:
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