• 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: Andrew Merenbach <email@hidden>
  • Date: Sat, 8 Dec 2007 11:38:58 -0800

On Dec 8, 2007, at 9:32 AM, David LeBer wrote:


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

Hi,

Note that the use of -[NSString cString] is rather deprecated at the moment (as of OS X 10.4), in favor of - (const char *)cStringUsingEncoding:(NSStringEncoding)encoding.

Cheers,
	Andrew
_______________________________________________

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>)
 >Re: detecting no internet connection (From: David LeBer <email@hidden>)

  • Prev by Date: Transformable Attributes
  • Next by Date: Re: Transformable Attributes
  • Previous by thread: Re: detecting no internet connection
  • Next by thread: Re: detecting no internet connection
  • Index(es):
    • Date
    • Thread