IMPORTANT: Reachability must use DNS to resolve the host name before it |
can determine the Reachability of that host, and this may take time on |
certain network connections. Because of this, the API will return |
NotReachable until name resolution has completed. This delay may be |
visible in the interface on some networks. |
|
|
The Reachability sample demonstrates the asynchronous use of the |
SCNetworkReachability API. You can use the API synchronously, but do not |
issue a synchronous check by hostName on the main thread. If the device |
cannot reach a DNS server or is on a slow network, a synchronous call to |
the SCNetworkReachabilityGetFlags function can block for up to 30 |
seconds trying to resolve the hostName. If this happens on the main |
thread, the application watchdog will kill the application after 20 |
seconds of inactivity. |
本文介绍了一个使用SCNetworkReachability API进行主机名异步检测的示例。由于主机名解析可能需要时间,在某些网络连接上可能会导致延迟。为了避免应用程序被监视器因长时间无响应而终止,不应在主线程上发起异步检查。

1216

被折叠的 条评论
为什么被折叠?



