Re: NSURLConnection canHandleRequest: succeeds even with no network

2008-05-24 Thread Jens Alfke


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

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: NSURLConnection canHandleRequest: succeeds even with no network

2008-05-24 Thread Sherm Pendley
On Sat, May 24, 2008 at 2:11 AM, Mike <[EMAIL PROTECTED]> 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?


>From what I gather, the "preflight" referred to in the docs is just a check
to see if a protocol class is registered to handle the scheme (http:, file:,
etc.). That is, it tells you if the proper machinery is in place to
*attempt* the connection, not whether the attempt will succeed or not. It
allows you  to distinguish between "I don't grok gopher" and actual
network-layer errors.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


NSURLConnection canHandleRequest: succeeds even with no network

2008-05-23 Thread Mike
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?


Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]