Re: [Tutor] exception problems in socket programming

2006-11-16 Thread Vinay Reddy
> 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

Re: [Tutor] exception problems in socket programming

2006-11-16 Thread Kent Johnson
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

Re: [Tutor] exception problems in socket programming

2006-11-15 Thread Chris Hengge
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

[Tutor] exception problems in socket programming

2006-11-15 Thread Vinay Reddy
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):