summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2011-08-12 22:32:41 +0000
committerAndrew Stitcher <astitcher@apache.org>2011-08-12 22:32:41 +0000
commit50db2424a6f0f148914ec06e4c13e46a7a5bc533 (patch)
tree7d2a344257556447e31f30c1c1c80d59aefff46c /qpid/python
parent5cf78f7400e1e08ea7e028b76a7dfa4ebcbe5915 (diff)
downloadqpid-python-50db2424a6f0f148914ec06e4c13e46a7a5bc533.tar.gz
QPID-3407: Add IPv6 connections to python
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1157276 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
-rw-r--r--qpid/python/qpid/util.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/qpid/python/qpid/util.py b/qpid/python/qpid/util.py
index e62bebdf24..82d5044264 100644
--- a/qpid/python/qpid/util.py
+++ b/qpid/python/qpid/util.py
@@ -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):