Re: NSURLConnection canHandleRequest: succeeds even with no network
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