Determining if a client PC has an Internet connection

Cliff Wells clifford.wells at comcast.net
Sun Sep 19 23:38:15 CEST 2004


On Sun, 2004-09-19 at 23:54 +0300, Tuure Laurinolli wrote:
> Cliff Wells wrote:
> 
> > 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).
> 
> I do not see why there would have to be specific online and offline 
> modes. They are annoying. Especially when they educatedly guess they are 
> not on the Internet and refuse to believe the user who says they are.

It doesn't refuse.  If you tell it that it's online it will faithfully
try to download whether it thinks it is or not.  You are making as many
assumptions as you claim my software will ;)

> > 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.
> 
> So why not assume you are always connected to the Internet. Download 
> updated info into local cache whenever possible and always show local 
> cached information. Of course you could somehow indicate the age of the 
> cached information, so the user doesn't think that local cached 
> information is up-to-date when it actually isn't.

Because it's a customer requirement.  Besides, as I outlined in a
separate post, there are actually a couple of good reasons for the app
to know when it's offline:

'''
More importantly, if the app is "online", timing out is returned as an
error to the user, whereas in the "offline" state, as long as the data
is cached, there is no error.  Also, in the case of being offline and
there is no data in the cache, the error message is to be different than
if the app is online and the connection fails.
'''

Regards,
Cliff

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




More information about the Python-list mailing list