简体   繁体   English

Android-InetAddress的最大超时isReachable()

[英]Android - Maximum Timeout for InetAddress isReachable()

I'm using InetAddress.getByName(params[0]).isReachable(300000) to determine if my NAS is alive. 我正在使用InetAddress.getByName(params [0])。isReachable(300000)来确定我的NAS是否还活着。 By measuring the time before and after the above methode I found out that the timeout has a maximum of about 3 min. 通过测量上述方法之前和之后的时间,我发现超时最大约为3分钟。 10 seconds, even if I set the timeout to 600000 (about 10 minutes). 即使我将超时设置为600000(大约10分钟)也要10秒。

Am I doing something wrong? 难道我做错了什么? Or is there a better way to implement such function? 或者有更好的方法来实现这样的功能吗?

regards, Thomas 问候,托马斯

I've changed my approach. 我改变了我的做法。 Now I'm using Runtime.getRuntime().exec to execute a ping to the remote-ip. 现在我使用Runtime.getRuntime()。exec对remote-ip执行ping操作。 That's more reliable than isReachable. 这比isReachable更可靠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM