Re: Efficient method of checking connectivity
Re: Efficient method of checking connectivity
- Subject: Re: Efficient method of checking connectivity
- From: Ryan McGann <email@hidden>
- Date: Mon, 31 May 2004 00:00:21 -0700
I'm currently on a dialup connection and I've noticed that this can
cause a delay of a few seconds, especially if there is activity going
on (e.g. downloading a file).
Is there any more efficient method of determining connectivity to the
internet?
Not really, since determining connectivity to the Internet depends on a
lot of factors. For example, the user may have an IP address (or
three), but none of them may be routable...they may be link-local
addresses that do nothing except route traffic on the "local" network
created by Mac OS X's link local addressing. If the user does have a
routable IP addresss, they still may not be able to reach the Internet
for a variety of other factors, such the ability to communicate with
the DNS servers.
It all depends really on what you need to check for. If you just want
to know if the user has a routable IP address, there are easier ways of
determining this. If you need to check that the user can reach a
particular server (such as your software update server) then you're
better off using the SCNetworkReachability APIs, since they do a lot
more checks then just a simple "do I have an IP address" check.
I've thought about spawning a thread on which I'll call the above, but
the SCNetwork.h file doesn't mention thread safety. I'm thinking that
such an approach will greatly cut down my app startup time. Any UI
that is brought up that needs the result of the connectivity check will
just wait for the thread. Odds are though that a decent amount of time
will occur before the user brings up any such UI.
The SystemConfiguration framework (which is where these APIs are
located) is open source (configd is the project name in Darwin). The
methods are thread-safe it would _look_ like (but somebody at Apple
would probably be better off answering that). However you can also use
the new APIs in Panther that allow you to use CFRunLoop to tell you
when the connection becomes available.
There are 10 kinds of people in the world: those that can understand
binary, and those that can't.
------------------------------------
Ryan McGann
Software Engineer
Macintosh Internet Security
Symantec Corporation
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.