[Tutor] Monitoring an Internet connection in Python
carroll at tjc.com
Wed Oct 13 21:50:04 CEST 2004
My DSL connection is pretty fragile, and tends to drop a lot, and for
extended periods. I'd like to write a Python program to periodicaly (say,
every 5 minutes or so) check the status of the Internet connection, and
log any change in status (detecting when it becomes unavailable and when
it becomes available again), so I can document the failures to SBC.
What's the best way to check whether my system has a working Internet
connection using Python? My thinking is to select a few IP addresses
known to be reliable, and to define "connection available" as being when
at least one of those sites responds to a ping. Is there a better way?
More information about the Tutor