isReachable 给出奇怪的结果
我正在尝试 ping LAN 网络上的计算机列表(地址存储在列表中)
while(listIterator.hasNext())
{
// listIterator.next() will give address for each computer
boolean bool = inetAddress.isReachable(timeout);
}
对于每次迭代,我只能 ping 一台计算机,其余的给出 false(所有计算机都在 LAN 上启动并运行)。 任何人都可以提出这个问题或有效的方法来做到这一点吗?
I am trying to ping a list of computers on LAN network (address stored in a list)
while(listIterator.hasNext())
{
// listIterator.next() will give address for each computer
boolean bool = inetAddress.isReachable(timeout);
}
For each iteration, I am only able to ping only one computer and rest giving false (All computers are up and running on LAN).
Can anyone suggest a problem in this or an efficient way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在 Linux 上运行吗?如果是这样,只有当您以 root 身份运行时,它才会真正起作用,因为发送“ping”需要 root 权限(真正的 ping 命令被设置为以 root 身份有效运行)。
尽管听起来很可怕,但最好的选择可能是生成“ping”命令并查看其退出代码。
Are you running on Linux? If so it will only really work if you are running as root, since sending the "pings" requires root privilege (The real ping command is set up to effectively run as root).
Horrible as it sounds, your best bet might be to spawn off a "ping" command and look at its exit code.