Android - InetAddress isReachable() 的最大超时

发布于 2024-10-07 09:31:49 字数 201 浏览 0 评论 0原文

我正在使用 InetAddress.getByName(params[0]).isReachable(300000) 来 确定我的 NAS 是否还活着。 通过测量上述方法前后的时间我发现 超时时间最长约为 3 分钟。 10秒,即使我 将超时设置为 600000(大约 10 分钟)。

我做错了什么吗?或者有没有更好的方法来实现这样的 功能?

问候, 托马斯

I'm using InetAddress.getByName(params[0]).isReachable(300000) to
determine if my NAS is alive.
By measuring the time before and after the above methode I found out
that the timeout has a maximum of about 3 min. 10 seconds, even if I
set the timeout to 600000 (about 10 minutes).

Am I doing something wrong? Or is there a better way to implement such
function?

regards,
Thomas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简单气质女生网名 2024-10-14 09:31:50

我改变了我的方法。现在我正在使用 Runtime.getRuntime().exec 对远程 IP 执行 ping 操作。这比 isReachable 更可靠。

I've changed my approach. Now I'm using Runtime.getRuntime().exec to execute a ping to the remote-ip. That's more reliable than isReachable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文