Re: detecting no internet connection
Re: detecting no internet connection
- Subject: Re: detecting no internet connection
- From: David LeBer <email@hidden>
- Date: Sat, 8 Dec 2007 12:32:11 -0500
On 8-Dec-07, at 12:14 PM, Denise Eatherly wrote:
Hi,
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.
I'm currently using something like this:
- (BOOL) isNetworkAvailable
{
BOOL result = NO;
SCNetworkConnectionFlags flags;
NSString *network;
network = someNetwork; // assume exists
if ( SCNetworkCheckReachabilityByName([network cString], &flags) )
{
result = !(flags & kSCNetworkFlagsConnectionRequired) &&
(flags & kSCNetworkFlagsReachable);
}
return result;
}
;david
--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site: http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org
_______________________________________________
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