Problem with isReachable in InetAddress class

前端 未结 3 1181
你的背包
你的背包 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:40

    I found interesting solution. If you can't run your aplication as root, you may set raw socket capability on java:

    sudo setcap cap_net_raw=ep /usr/lib/jvm/jdk/bin/java
    

    And then ICMP protocol will be used istead of echo request on 7 TCP port.

提交回复
热议问题