Measuring Internet connection time

Létezõ letezo at fw.hu
Tue Mar 4 14:30:31 EST 2003


> Is there an easy way using Python to check if the computer (Windows XP) is
> connected to the Internet?
> I've tested a few programs I've found at download.com, but they either
> assume that I connect through a phone, which I don't, or they complain
about
> som file,
> usually some .dll.

I know about the following solutions:

- Ping periodically a known IP address (for example your ISP's server), if
the ping fails the connection is down. Reliable, but ugly solution. Costs
some bandwidth and keeps your connection. Simple to implement. Time
precision depends on the poll frequency.

- Call InternetGetConnectedState function from Wininet.dll, this returns a
boolean value for you. Does not keep your connection. Time precision depends
on the poll frequency. No information about it's reliability.

- Get the output of "ipconfig /all" command. (Try it on the command line.)
Check if the DNS of your ISP is in the text. Ugly solution, but does not
cost any bandwidth and don't keep your connection up.

It's a good idea to do connection time statistics with python.

Best wishes, Viktor







More information about the Python-list mailing list