iOS网络可达性 – 似乎不起作用

我正在关注 How to check for an active Internet connection on iOS or OSX?http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html以测试连接性,但我遇到了一些非常基本的问题.

例如,我正在从另一台机器上运行.NET API,然后尝试通过我的mac mini连接到它.

1)当IIS运行时,一切都正常运行,我很高兴我得到了这个工作!

2)我可以完全关闭IIS(很明显,主机无法访问),但我的reachabilityWithHostName仍然报告主机可以访问.

有任何想法吗?

解决方法

SCNetworkReachability Reference.

The SCNetworkReachability programming
interface allows an application to
determine the status of a system’s
current network configuration and the
reachability of a target host. 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.

打开和关闭IIS只会阻止您的服务器接收诸如ftp / http之类的Web请求,并且不会阻止设备成功发送数据包.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...