• 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: How to know if Internet connection is active?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to know if Internet connection is active?


  • Subject: Re: How to know if Internet connection is active?
  • From: Angela Brett <email@hidden>
  • Date: Tue, 6 Aug 2002 22:40:51 +1200

Hi,

In case the user uses a modem to connect to the Internet, and the connection
is not running, what happens when you call [... InitWithContentsOfURL]
methods or [NSWorkspace openURL]?

Do they simply return nil or do they make the modem connect to the Internet?

I would assume they'd make the modem connect to the internet iff the computer is set up to do so in Network Preferences... I haven't tried though. I guess I shouldn't have answered that question since I don't know for sure, but I can answer your other question.


In the second case, is there any way in Cocoa to know if the computer is
connected to the Internet before calling any Cocoa method that might attempt
to do so?

I included SystemConfiguration.framework in my project, and use this method:

BOOL networkReachableWithoutAnythingSpecialHappening(void) {
Boolean Success;
SCNetworkConnectionFlags ReachabilityStatus;
Success = SCNetworkCheckReachabilityByName("www.apple.com" &ReachabilityStatus);
return (Success && (ReachabilityStatus & 3));
}

3 is kSCNetworkFlagsTransientConnection|kSCNetworkFlagsReachable, I chose that because it means the internet can be reached without any user intervention or automatic dialling of the modem... but you should look at the values in SCNetwork.h in SystemConfiguration.framework and decide for yourself. You can change the hostname to whatever you like, I don't think it makes a difference.
--
Angela Brett
Email: email@hidden
Homepage: http://acronyms.co.nz/angela
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >How to know if Internet connection is active? (From: Pierre-Olivier Latour <email@hidden>)

  • Prev by Date: Re: Accessor methods and (auto)release: conclusion
  • Next by Date: Re: Distributed Objects over a Network
  • Previous by thread: How to know if Internet connection is active?
  • Next by thread: Archive crash
  • Index(es):
    • Date
    • Thread