Re: Checking for Internet Connection in an iApp
Re: Checking for Internet Connection in an iApp
- Subject: Re: Checking for Internet Connection in an iApp
- From: Jens Alfke <email@hidden>
- Date: Sun, 16 Oct 2011 17:49:26 -0700
On Oct 16, 2011, at 2:45 PM, John Love wrote:
> Maybe my method of "taking my connection" down may be in error -- I am simply pushing off the "standby" button on my cable modem -- I have also just unplugged the modem.
That’s not an error, but it’s kind of a worst-case scenario for reachability detection. As far as the device is concerned, it has no idea anything has changed. It’s just that the next time it tries to send any IP packets, they won’t go anywhere because the WiFi router doesn’t have anyplace to forward them to. And the only way it finds out they didn’t go anywhere is when it doesn’t get any response packets from the destination within the appropriate IP timeout.
It’s a common misconception that devices on a network are constantly communicating with each other to let each other know when they’re available. In fact this would cause a lot of congestion, so it’s only done for specific services that want to be able to discover each other, e.g. by Bonjour.
On the other hand, the device *can* tell when the WiFi router goes down (or out of range) because it’s got a radio connection with it that can be continuously monitored. That’s happening below the IP layer.
By analogy: If the mail carrier stops coming to my house, I know I can’t send a letter to you. But if my local post office stops shipping mail to other post offices, I can’t tell anything’s wrong until I try to send you a letter and wait a week or more without getting a reply.
> Isn't the function of -startNotifier to enable the callback method to be continuously called within the main RunLoop?
> Yet the only time I can get this callback method to be called is if I call NSNotificationCenter's -postNotificationName elsewhere in the code??
You’re not going to be notified that reachability changed, because your TCP/IP stack has no idea that it changed, as I explained above.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden