iOS network reachability - doesn't seem to be working

Buchannon picture Buchannon · May 3, 2011 · Viewed 8.2k times · Source

I'm following How to check for an active Internet connection on iOS or OSX? and http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html to test for connectivity, but am running into some pretty basic issues.

For example, I'm running a .NET API off of another machine and then trying to connect to it via my mac mini.

1) When IIS is running, everything is working like it should, I was excited that I got this working!

2) I can shut off IIS completely (obviously, host is unreachable) but my reachabilityWithHostName is still reporting that the host is reachable.

Any ideas?

Answer

Joe picture Joe · May 3, 2011

See the 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.

Turning IIS on and off is just preventing your server from receiving web request such as ftp/http and does not stop the device from successfully sending a data packet out.