getting socket.bind() exception, but no actual error
Clarence Gardner
clarence at silcom.com
Mon Nov 1 13:45:31 EST 2004
I've got a problem that I don't see how to program around. A socket server
that was running fine, today started getting an exception from the bind()
call (errno 22, Invalid argument) and yet the bind had actually worked.
This is apparent from this code: it prints the error message, but then
breaks out of the loop and the listen() and accept() calls work normally.
How can one handle a function that is both working and raising an
exception?
sockobj=socket(AF_INET,SOCK_STREAM)
while True:
try:
sockobj.bind(('',4321))
except socketerror,e:
print e
if str(e).find('in use') == -1:
break
print '.'
time.sleep(1)
sockobj.listen(5)
More information about the Python-list
mailing list