Re: detecting an active Internet connection
Re: detecting an active Internet connection
- Subject: Re: detecting an active Internet connection
- From: Evan Schoenberg <email@hidden>
- Date: Tue, 26 Oct 2004 14:58:01 -0500
CreateIPAddressListChangeCallbackSCF() is also worth looking at; you can have a callback which is triggered when the system's connectivity changes.
So far as I can tell none of the OS X APIs provide perfect internet connectivity checking; they can be fooled by an active connection to a router which itself has no internet connection, for example. If anyone has a way of determining connectivity in that (and similar) cases, I'd love to know about it.
Also, I usually get hit with 4 or 5 callback triggers, with alternating connected/not-connected values, when the internet goes up or down; I use an NSTimer to aggregate these results, as the last one is the appropriate (true) one.
Your ping check would actually solve this case, though there's no way to know when to try again if the check fails. I wonder if using the
CreateIPAddressListChangeCallbackSCF() callback and then performing a ping check instead of relying upon the passed flags would be a viable solution.
-Evan Schoenberg
Lead Developer, Adium X
www.adiumx.com
On Oct 26, 2004, at 12:54 AM, Donald Hall wrote:
Looking back in the archives of this list, I have found several schemes using
SCNetworkCheckReachabilityByName()
to attempt to determine if the Internet was reachable without actually triggering a connection attempt.
It seems to me that using "ping" through an NSTask would also work. When I try
ping -c1 www.apple.com
with a dialup connection, an error (unknown host) is returned if I am not connected (and therefore www.apple.com is not reachable). No attempt is made to automatically activate my modem and dial out even if I have selected automatically connect in Network preferences.
Any comments? Am I missing something?
Thanks,
Don
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
email@hidden
http://www.appsandmore.com
_______________________________________________
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