SCNetworkReachabilityGetFlags 给出错误结果
我们使用 SCNetworkReachabilityGetFlags 来确定是否可以连接互联网。在某些手机上,它偶尔会提供错误信息,表示无法访问某些主机或 IP 地址。当忽略标志并无论如何发起请求时,一切正常。
这个答案表明再次打开和关闭飞行模式会释放 SCNetworkReachabilityGetFlags 可能正在使用的缓存: 即使无线可用,SCNetworkReachabilityGetFlags也会返回0
显然这不是一个真正的选项从可用性的角度来看。有人遇到过同样的问题吗?是否有其他方法来检查可达性?
Possible Duplicate:
SCNetworkReachabilityGetFlags returns 0 even when wireless available
We are using SCNetworkReachabilityGetFlags to determine if internet connectivity is available. On certain phones it does occasionally provide wrong information, saying that some host or ip address can not be reached. When ignoring the flags and launching a request anyway, everything works fine.
This answer suggests that switching airplane mode on and off again releases a cache SCNetworkReachabilityGetFlags might be using:
SCNetworkReachabilityGetFlags returns 0 even when wireless available
Obviously this is not really an option from a usability perspective. Has any one encountered the same problem? Are there alternatives for checking the reachability?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的工作是重置网络设置。
My be Resetting the network settings my work.
您还可以使用 NSURL 的一个很好的方法,
NSURL 开发者文档
如果您想在网络离线(或在线时)时收到通知,这当然不是很有用重要)就像您可以对系统配置所做的那样。
在我的 Mac 即时通讯应用程序中,我有一个看门狗(20 秒计时器),因为系统配置对我来说并不总是足够可靠。
You could also use a nice method of NSURL,
NSURL Developer documentation
This of course would not be very useful if you want to receive a notification when the network goes offline ( or online for that matter ) like you can do with System Configuration.
In my IM application for tha Mac I have a watchdog ( 20 second timer ) because SystemConfiguration was not always reliable enough for me.