Why does InetAddress.isReachable return false, when I can ping the IP address?

后端 未结 10 1582
陌清茗
陌清茗 2020-11-22 12:24
InetAddress byName = InetAddress.getByName("173.39.161.140");
System.out.println(byName);
System.out.println(byNam         


        
10条回答
  •  一整个雨季
    2020-11-22 12:37

    InetAddress.isReachable is flappy, and sometimes returns unreachable for addresses which we can ping.

    I tried the following:

    ping -c 1 and check the exit status.

    Works for all the cases i had tried where InetAddress.isReachable doesn't work.

提交回复
热议问题