• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: detecting no internet connection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >detecting no internet connection (From: Denise Eatherly <email@hidden>)

  • Prev by Date: Re: NSTableView, NSArrayController and secondary sortings
  • Next by Date: Re: NSTableView, NSArrayController and secondary sortings
  • Previous by thread: Re: detecting no internet connection
  • Next by thread: Spotlight Query: can't get relevant relevance
  • Index(es):
    • Date
    • Thread