Determining if a client PC has an Internet connection

Thorsten Kampe thorsten at thorstenkampe.de
Sun Sep 19 04:25:23 EDT 2004


* Jarek Zgoda (2004-09-19 10:14 +0200)
> Cliff Wells <clifford.wells at comcast.net> pisze:
>> 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?
> 
> No, there's no such way.

I think there has to be (or at least there is a method that many
coders use because "testing if you're online" is a very frequent
problem).

Thorsten



More information about the Python-list mailing list