How to get socket errors from 'connect'?
Doug Fort
dougfort at downright.com
Thu Apr 12 14:01:44 EDT 2001
>
Try catching 'socket.error'. It includes a tuple of the form (errocode,
explanation)
> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> try:
> val=sock.connect((url, port))
except socket.error, errortuple:
print "socket error %s %s" % errortuple
.....
>
> except Exception:
> print 'no luck connecting'
> sock.close()
> del sock
> print val
> sys.exit()
>
--
Doug Fort (dougfort at downright.com)
Senior Meat Manager
Downright Software LLC
http://www.dougfort.net
More information about the Python-list
mailing list