qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r1157276 - /qpid/trunk/qpid/python/qpid/util.py
Date Fri, 12 Aug 2011 22:32:41 GMT
Author: astitcher
Date: Fri Aug 12 22:32:41 2011
New Revision: 1157276

URL: http://svn.apache.org/viewvc?rev=1157276&view=rev
Log:
QPID-3407: Add IPv6 connections to python

Modified:
    qpid/trunk/qpid/python/qpid/util.py

Modified: qpid/trunk/qpid/python/qpid/util.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/util.py?rev=1157276&r1=1157275&r2=1157276&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/util.py (original)
+++ qpid/trunk/qpid/python/qpid/util.py Fri Aug 12 22:32:41 2011
@@ -39,12 +39,17 @@ except ImportError:
       self.sock.close()
 
 def connect(host, port):
-  sock = socket.socket()
-  sock.connect((host, port))
-  sock.setblocking(1)
-  # XXX: we could use this on read, but we'd have to put write in a
-  # loop as well
-  # sock.settimeout(1)
+  for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
+    af, socktype, proto, canonname, sa = res
+    sock = socket.socket(af, socktype, proto)
+    try:
+      sock.connect(sa)
+      break
+    except socket.error, msg:
+      sock.close
+  else:
+    # If we got here then we couldn't connect (yet)
+    raise
   return sock
 
 def listen(host, port, predicate = lambda: True, bound = lambda: None):



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message