[Tutor] exception problems in socket programming
Vinay Reddy
vinayvinay at gmail.com
Thu Nov 16 04:03:31 CET 2006
Hi,
I'm trying to do some simple network programming in Python, but am
stuck with exception problems. Here's the relevant code snippet:
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
self.s.connect((something.com, 5000))
except socket.error, (value, message):
if self.s:
self.s.close()
print "Could not open socket: " + message
sys.exit(1)
I was testing for a timeout exception (which is 60 seconds by
default), but after the timeout I get the following error:
File "./client.py", line 54, in connect
except socket.error, (value, message):
ValueError: need more than 1 value to unpack
I googled and found something on ValueError, but I couldn't see how it
applied here.
I'd appreciate any help.
Thanks,
Vinay
More information about the Tutor
mailing list