• 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: NSURLConnection canHandleRequest: succeeds even with no network
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection canHandleRequest: succeeds even with no network


  • Subject: Re: NSURLConnection canHandleRequest: succeeds even with no network
  • From: Jens Alfke <email@hidden>
  • Date: Sat, 24 May 2008 14:25:54 -0700


On 23 May '08, at 11:11 PM, Mike wrote:

Why does [ NSURLConnection canHandleRequest: ] return YES even if I turn off all my network connections? I thought this method was supposed to be used for preflighting connection requests?

No, it just tells you whether there's support for that URL scheme (http:, ftp:, etc.)


If you want to tell whether the host is reachable, you need to use the System Configuration API — look up the docs for SCNetworkCheckReachabilityByName. (I also just noticed CFHostGetReachability, which looks like a higher-level interface that might be easier to call.)

Even this just checks the system's network interfaces and routing tables to decide whether the kernel knows how to route a packet towards that address — it does _not_ actually try to contact the server, so it can't tell you if there's a broken gateway, or the server is down, or it's not listening on the port you want to connect to, etc.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: 
 >NSURLConnection canHandleRequest: succeeds even with no network (From: Mike <email@hidden>)

  • Prev by Date: Re: How to tell if iTunes is running.
  • Next by Date: Re: File's Owner
  • Previous by thread: Re: NSURLConnection canHandleRequest: succeeds even with no network
  • Next by thread: Change the Language of just one Application
  • Index(es):
    • Date
    • Thread