How to test if connected to the Internet

Grant Edwards grante at visi.com
Mon May 7 23:46:44 EDT 2001


On Mon, 07 May 2001 22:57:45 GMT, Ron Johnson <ron.l.johnson at home.com> wrote:

>> Is there some (easy) example code available which lets me check if a
>> connection to the Internet is established or not?  If not, how can I
>> dial-in to my ISP using Python?
>
>If using Linux/Unix, you could always try 
>  /sbin/ifconfig eth0 |grep eth0
>and if you find eth0, then proceed with your Python script.

That only tells you if there's an ethernet driver loaded.  You
still might not have an Internet connection.  Or you're
internet connection could be through a PPP or SLIP or PLIP
device.

The only way to determine if a particular IP address is
reachable is to try to open a connection.

-- 
Grant Edwards                   grante             Yow!  Sorry, wrong ZIP
                                  at               CODE!!
                               visi.com            



More information about the Python-list mailing list