Determining if a client PC has an Internet connection
Fredrik Lundh
fredrik at pythonware.com
Sun Sep 19 05:46:18 EDT 2004
More information about the Python-list mailing list
Sun Sep 19 05:46:18 EDT 2004
- Previous message (by thread): Determining if a client PC has an Internet connection
- Next message (by thread): Determining if a client PC has an Internet connection
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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). on windows, you can use InternetCheckConnection: http://msdn.microsoft.com/library/en-us/wininet/wininet/internetcheckconnection.asp (it should be available via win32all; if not, use ctypes). > 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. another solution would be to use asynchronous sockets, and only up- date the local cache when you get new data from the server (set a flag in the user interface if the server times out; if all channels are flagged, the users will probably figure things out by themselves). bits and pieces: http://effbot.org/zone/effnews-1.htm (asynchronous client) http://effbot.org/zone/effnews-2.htm (parsing) http://effbot.org/zone/effnews-3.htm (connection management) </F>
- Previous message (by thread): Determining if a client PC has an Internet connection
- Next message (by thread): Determining if a client PC has an Internet connection
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list