可可 – 使用网络链路调节器测试可达性100%丢包:帮助我了解正在发生的事情

可可 – 使用网络链路调节器测试可达性100%丢包:帮助我了解正在发生的事情,第1张

概述帮助我理解在使用网络链接调节器测试可达性代码时所看到的内容.这是我的香草可达性代码: Reachability* wifiReach = [[Reachability reachabilityWithHostName: @"www.apple.com"] retain];NetworkStatus netStatus = [wifiReach currentReachabilityStatus] 帮助我理解在使用网络链接调节器测试可达性代码时所看到的内容.这是我的香草可达性代码:

Reachability* wifiReach = [[Reachability reachabilityWithHostname: @"www.apple.com"] retain];NetworkStatus netStatus = [wifiReach currentReachabilityStatus];switch (netStatus){    case NotReachable:    {        NSLog(@"Access Not Available");        break;    }    case ReachableViaWWAN:    {        NSLog(@"Reachable WWAN");        break;    }    case ReachableViaWiFi:    {        NSLog(@"Reachable WiFi");        break;    }}

现在,当我使用网络链接调节器使用“100%丢失”预设测试此代码时 – netStatus的值是ReachableViaWWAN,这是我没想到的.我读了很多关于Reachability没有真正测试连接性的投诉,而是测试了连接的可能性.所以这是我的问题:

“100%丢失”预设是否允许向Apple服务器发出DNS请求,但不允许任何数据包通过?

解决方法 这可能与事实有关,即Reachability不能保证数据包实际可以到达目标主机.它是关于本地网络配置(接口向上/向下)以及它是否可以发送数据包.

来自Apple的SCNetworkReachability Reference:

A remote host is consIDered reachable when a data packet,sent by an application into the network stack,can leave the local device. Reachability does not guarantee that the data packet will actually be received by the host.

因此,如果接口已启动且Reachability可以发送包,则会满足并返回状态可达.

来自Apple的开发人员指南Why Networking is hard:

important: The SCNetworkReachability API is not intended for use as a preflight mechanism for determining network connectivity. You determine network connectivity by attempting to connect. If the connection fails,consult the SCNetworkReachability API to help diagnose the cause of the failure.

总结

以上是内存溢出为你收集整理的可可 – 使用网络链路调节器测试可达性100%丢包:帮助我了解正在发生的事情全部内容,希望文章能够帮你解决可可 – 使用网络链路调节器测试可达性100%丢包:帮助我了解正在发生的事情所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1023115.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存