Measuring Internet connection time

Peter Hansen peter at engcorp.com
Tue Mar 4 17:32:57 EST 2003


Dave Brueck wrote:
> 
> You can simply try to connect to some well-known host
> like google.com, but if the Windows user has a modem configured to
> autodial then doing so will cause the modem to dial up their ISP.

Besides, I'd say it's bad citizenship to use a server like google.com
for something like checking connectivity to the Net, unless it's specifically
connectivity to google.com which is the concern.

The only really appropriate way is probably to parse the output of 
"route print" (under Windows) or "route" (under Linux) and try to ping
your default gateway.  If that doesn't work, you're not on the Net.  If
it does work, you may be on the net...  of course, you don't even
need to ping it if you have a non-persistent connection: just check
whether you even *have* a default gateway set up and if you don't,
you aren't on the Net.

-Peter




More information about the Python-list mailing list