Problem with isReachable in InetAddress class

前端 未结 3 1182
你的背包
你的背包 2020-12-03 17:51

As an assignment I have to find all the alive computers on a LAN. For which I am using isReachable function of InetAddress class. But problem is

3条回答
  •  感动是毒
    2020-12-03 18:42

    Here are some details on why isReachable() might not always work as expected

    1. http://bordet.blogspot.com/2006/07/icmp-and-inetaddressisreachable.html
    2. http://www.coderanch.com/t/206934/sockets/java/InetAdress-isReachable-Ping-Permissions

    The correct way for you is to use the ICMP protocol. This is what ping uses internatlly, I believe. Here is an example that get you started.

提交回复
热议问题