> in other words you are tuple-unpacking the exception. Since it is not a
> tuple, but a single value, you get an error. Try this:
>except socket.error, e:
> if self.s:
> self.s.close()
> print "Could not open socket: " + e.message
Thanks a lot! I had to ma
Vinay Reddy wrote:
> 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))
> exce
I ran this code based on yours:
import socket, sys
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect(('something.com', 5000))
except socket.error, (value, message):
if s:
s.close()
print "Could not open socket: " + message
raw_input("\nPress any key")
And I got
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):