SCNetworkReachabilityGetFlags 给出错误结果

发布于 2024-12-15 09:04:54 字数 648 浏览 7 评论 0原文

可能的重复:
即使无线可用,SCNetworkReachabilityGetFlags也会返回 0

我们使用 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 技术交流群。

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

发布评论

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

评论(2

听风念你 2024-12-22 09:04:55

我的工作是重置网络设置。

My be Resetting the network settings my work.

梦归所梦 2024-12-22 09:04:55

您还可以使用 NSURL 的一个很好的方法,

- (BOOL)checkResourceIsReachableAndReturnError:(NSError **)error

NSURL 开发者文档

如果您想在网络离线(或在线时)时收到通知,这当然不是很有用重要)就像您可以对系统配置所做的那样。

在我的 Mac 即时通讯应用程序中,我有一个看门狗(20 秒计时器),因为系统配置对我来说并不总是足够可靠。

You could also use a nice method of NSURL,

- (BOOL)checkResourceIsReachableAndReturnError:(NSError **)error

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.

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