当连接到没有互联网的WIFI时,可达性需要太长时间才会失败 [英] Reachability takes too long to fail when connected to WIFI without internet

查看:181
本文介绍了当连接到没有互联网的WIFI时,可达性需要太长时间才会失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi there
我一直在使用可达性类,一切工作正常;除了...

Hi there I have been using reachability class and everything works fine; except for ...

当设备连接到wifi,无论什么原因,wifi路由器没有互联网连接可达性类花太长时间说没有互联网。

When the device is connected to wifi, and for whatever reason, the wifi router does not have internet connectivity the reachability class takes too long to say that there is no internet.

当没有网络/互联网连接时,它工作得很好(快!),例如,如果wifi关闭,没有3G连接,可达性类几乎立即返回成功/失败。

It works well(fast!) when there is no network/internet connectivity at all, for instance, if the wifi is off and the device does not have a 3G connection, reachability class returns success/failure almost instantly.

要重新连接,连接到无线路由器,

To re-iterate, connected to a wifi router, where there is no internet connectivity almost takes a full minute for reachability class to return a status.

Reachability *reachability=[Reachability reachabilityWithHostName:@"www.google.com"];
    NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
    if(remoteHostStatus == NotReachable) { 
 ............

我的代码

有任何建议吗?

感谢

推荐答案

我刚刚尝试过

Reachability *reachability=[Reachability reachabilityForInternetConnection];

看起来工作正常!因为我只是想看看互联网是否可用。

Looks like it works! Since i just wanted to see if the internet is available or not

感谢

这篇关于当连接到没有互联网的WIFI时,可达性需要太长时间才会失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆