• 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 Internet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting Internet


  • Subject: Re: Detecting Internet
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Fri, 14 Jul 2006 06:33:19 -0700


On Jul 14, 2006, at 02:12, Gerriet M. Denkmann wrote:


When my app runs on a computer which connects to the internet via the internal modem then the SCNetworkReachability... functions work very well.
If no internet is available Safari shows a page "You are not connected to the..." immediately, and [NSHost hostWithName: ] returns nil at once.


But when the computer accesses the internet through the Build-in Ethernet then the reachability functions don't help.
And in this case Safari takes 2 minutes to detect the absence of an internet connection; NSHost takes 1 minute to return nil.

What do you mean when you say they don't help? I'm using the following code (gleaned from the list archives) in a couple of applications, and it works equally well with modem, Ethernet, and Airport.


    BOOL result = NO;
    SCNetworkConnectionFlags flags;
    const char *hostName = "myhost.mydomain.com";

if( SCNetworkCheckReachabilityByName(hostName, &flags) ){
result = !(flags & kSCNetworkFlagsConnectionRequired) && (flags & kSCNetworkFlagsReachable);
}



-- adam _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Detecting Internet (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: RTFFromRange:documentAttributes: and Windows incompatibility?
  • Next by Date: Re: RTFFromRange:documentAttributes: and Windows incompatibility?
  • Previous by thread: Re: Detecting Internet
  • Next by thread: Re: Detecting Internet
  • Index(es):
    • Date
    • Thread