Testing for Internet Connection

Venky Shankar vshankar0 at gmail.com
Thu Jul 17 13:58:57 CEST 2008


may be try to open a connection to 4.2.2.2 at port 53 ?

-vks

On Wed, Jul 16, 2008 at 12:13 AM, norseman <norseman at hughes.net> wrote:

>
> Grant Edwards wrote:
>
>> On 2008-07-15, Alexnb <alexnbryan at gmail.com> wrote:
>>
>>  What exactly do you think will work? I am not sure what you
>>> think I should do? If I use urlopen("http://www.google.com")
>>> and I am not connected, I am not going to get an exception,
>>> the program will fail.
>>>
>>
>> Bullshit.  You get an exception.  Here's my program:
>>
>>   import urllib2
>>   try:
>>       con = urllib2.urlopen("http://www.google.com/")
>>       data = con.read()
>>       print data
>>   except:
>>       print "failed"
>>
>> If I run it with no internet connection, I get this:
>>
>>   $ python testit.py
>>   failed
>>
>> If I bring up the internet connection, then I get a bunch of
>> HTML.
>>
> =============================
> Yep -me two
>
> Process:
> copy/paste into afile
> slide lines left to create proper indent values
> save
> python afile
>
> I get same as Grant
>
>
> If one does a copy/paste into interactive Python, it does fail.
> (Lots of indent error messages.  After all, it is Python :)
>
>
> Steve
> norseman at hughes.net
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080717/840af166/attachment.html>


More information about the Python-list mailing list