Re: detecting no internet connection
Re: detecting no internet connection
- Subject: Re: detecting no internet connection
- From: Chris Hanson <email@hidden>
- Date: Sat, 8 Dec 2007 21:16:21 -0800
On Dec 8, 2007, at 9:14 AM, Denise Eatherly wrote:
Does anyone know a good way to detect whether a user has an internet
connection? NSURL does the right thing unless there is an active
airport with no connection. I tried using NSURLRequest. That is a
little better, but it doesn't seem to make any difference what
number I use for the timeout value. It seems to try for an awfully
long time before it gives up. Any suggestions are greatly
appreciated.
There really isn't any good way to do this, based on the architecture
of the Internet itself. Your best bet is to check the network
reachability (using the SystemConfiguration.framework functions
mentioned by David LeBer) for the specific host you're trying to access.
To expand a bit: You can be on the Internet, but with something along
your route that prevents a specific host from being reachable. You
can be on a private network -- even one with self-assigned or
otherwise-unroutable IP addresses, such as those in the 10.* range or
192.168.* range -- that prevents general Internet access, but creates
tunnels on demand to specific hosts. And so on.
Fundamentally, you can't anticipate all such situations at design
time. So rather than trying to detect whether there is an Internet
connection (for some specific definition of "Internet connection" that
may not match the user's network), you need to code to be as robust as
possible: Perform specific actions against specific hosts, generally
in a concurrent fashion, and handle the exceptional cases appropriately.
-- Chris
_______________________________________________
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