socket.error
Doug Fort
dougfort at downright.com
Fri Feb 16 21:29:33 EST 2001
Here's how we do it. Note that you must 'import socket'. The 'message'
object is usually a tuple.
except socket.error, message:
self._message = "Socket Error: %s" % (str(message))
--
Doug Fort
Senior Meat Manager
Downright Software LLC
"Gustaf Liljegren" <gustafl at algonet.se> wrote in message
news:Xns904B3C674D9gustaflalgonetse at 194.213.69.148...
> I'm using 1.5.2 in Windows 98.
>
> When running the httplib module I get the following error when using a
non-
> existing host name:
>
> Traceback (innermost last):
> File "httptest.py", line 28, in ?
> h = httplib.HTTP(domain)
> File "d:\python\Lib\httplib.py", line 51, in __init__
> if host: self.connect(host, port)
> File "d:\python\Lib\httplib.py", line 79, in connect
> self.sock.connect(host, port)
> File "<string>", line 1, in connect
> socket.error: host not found
>
> The code to produce this error is simply:
>
> import httplib
> h = httplib.HTTP('www.nonvalidhost.com')
>
> Python doesn't seem to like when I write "except socket.error:", so I
> wonder how to handle it properly.
>
> Regards,
>
> Gustaf Liljegren
More information about the Python-list
mailing list