Determining if a client PC has an Internet connection

Cliff Wells clifford.wells at comcast.net
Sun Sep 19 03:18:21 EDT 2004


Hi,

I'm writing an application that needs to know if an Internet connection
is available.  Basically, I want to have something similar to what a lot
of email clients have, where the app can work either in "online" or
"offline" mode (it keeps a cache of downloaded info, so it can work
without a connection if needed).

The basic problem is this: it downloads info (RSS feeds) from a variety
of sources.  Any one (or more) of these could conceivably fail to
download, so simply waiting for a timeout isn't sufficient (not easy to
differentiate between having a bad server and the client not having a
connection).  Further, if it waits (say 30s) for the timeout to occur,
this is going to be a bit annoying to the user.

I've considered trying to connect to a stable host (i.e. Google) and if
that fails then assume the client can't connect to the internet, but
this seems like a sub-optimal solution.

Is there any way to reliably determine the state of the client's
internet connectivity?

Regards,
Cliff

-- 
Cliff Wells <clifford.wells at comcast.net>




More information about the Python-list mailing list