问题描述
我使用Stackmob SDK(即将结束),并假设他们使用AFNetworking来实现可访问性。如果设备连接到与Internet断开连接的wifi网络,则可达性检查将为肯定,并且以下说法将成立:
I use Stackmob SDK (which will end soon) and I assume they use AFNetworking for reachability. If a device is connected to a wifi network which is disconnected from the Internet, the reachability check will be positive and the following statement will be true:
if ([self.appDelegate.client.networkMonitor currentNetworkStatus] == SMNetworkStatusReachable) {
// reachable
}
如何微调这张支票以克服目前的限制?如何在if语句中检查实际的网络可达性,或者在那里有更好的可达性检查?
How can I fine tune this check to overcome the present limitation? How can I check for real network reachability within this if statement, or is there any better Reachability check out there?
推荐答案
如果问题是我可以将数据发送到该主机并接收响应,那么可达性只能回答否或也许。它不能回答是,因为可达性不检查很多连通性因素。
If your question is "can I send data to that host and receive a response", then Reachability can only answer "no" or "maybe". It cannot answer "yes" because there are many connectivity factors that Reachability does not check.
可达到性仅检查第一跳。它将可达性定义为数据包向该主机方向离开设备的能力。如果设备连接到声称能够路由到该主机的网络,则可达到性得到满足。如果路由器在撒谎或主机掉线,或者堪萨斯州有不友好的反铲,那么可达性的结果将是乐观的。
Reachability only checks the first hop. It defines reachability as the ability for packets to leave the device in the direction of that host. If the device is connected to a network that claims to be able to route to that host then Reachability is satisfied. If the router is lying or the host is down or there are unfriendly backhoes in Kansas then Reachability's result will be optimistic.
唯一可以肯定地回答这个问题的方法 将数据发送到该主机并接收响应实际上是尝试将数据发送到该主机并接收响应。当连接性绝对不可用时,可到达性可以帮助您放弃。如果尝试失败,Reachability的网络更改通知可以帮助您决定何时重试而不会浪费电源。
The only sure way to answer the question "can I send data to that host and receive a response" is to actually attempt to send data to that host and receive a response. Reachability can help you give up when connectivity is definitely not available. If you try and fail, Reachability's network-change notifications can help you decide when to try again without wasting power.
这篇关于关于断开的wifi网络的可达性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!