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 this result:
Could not open socket: getaddrinfo failed

Press any key

Do you need to put quotes around something.com like I did?

On 11/15/06, Vinay Reddy <[EMAIL PROTECTED]> 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))
      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
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to