summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/windows_utils.py
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2014-03-17 05:54:05 (GMT)
committerLarry Hastings <larry@hastings.org>2014-03-17 05:54:05 (GMT)
commit3c5c56f3c068bc13daea2275b951113b43a91e85 (patch)
tree1395bfb10902b7087a4ca1551f4bdb271b55ed43 /Lib/asyncio/windows_utils.py
parente41b73caca2b543422f423a2ac07c29de834f44d (diff)
parent2221f666eba4a6f46f2095a801bc3e4bdbdb97d2 (diff)
downloadcpython-3c5c56f3c068bc13daea2275b951113b43a91e85.zip
cpython-3c5c56f3c068bc13daea2275b951113b43a91e85.tar.gz
cpython-3c5c56f3c068bc13daea2275b951113b43a91e85.tar.bz2
Merged default into 3.4 branch. 3.4 branch is now effectively 3.4.1rc1.
Diffstat (limited to 'Lib/asyncio/windows_utils.py')
-rw-r--r--Lib/asyncio/windows_utils.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/asyncio/windows_utils.py b/Lib/asyncio/windows_utils.py
index aa1c064..2a196cc 100644
--- a/Lib/asyncio/windows_utils.py
+++ b/Lib/asyncio/windows_utils.py
@@ -36,12 +36,25 @@ def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0):
Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain.
"""
+ if family == socket.AF_INET:
+ host = '127.0.0.1'
+ elif family == socket.AF_INET6:
+ host = '::1'
+ else:
+ raise ValueError("Ony AF_INET and AF_INET6 socket address families "
+ "are supported")
+ if type != socket.SOCK_STREAM:
+ raise ValueError("Only SOCK_STREAM socket type is supported")
+ if proto != 0:
+ raise ValueError("Only protocol zero is supported")
+
# We create a connected TCP socket. Note the trick with setblocking(0)
# that prevents us from having to create a thread.
lsock = socket.socket(family, type, proto)
- lsock.bind(('localhost', 0))
+ lsock.bind((host, 0))
lsock.listen(1)
- addr, port = lsock.getsockname()
+ # On IPv6, ignore flow_info and scope_id
+ addr, port = lsock.getsockname()[:2]
csock = socket.socket(family, type, proto)
csock.setblocking(False)
try: