Commit 21bcdfbf authored by Sam Rushing's avatar Sam Rushing

Merge pull request #47 from sgalaburda/fix-create-connection

Fixed create_connection() to match the emulated one.
parents f9c12264 f523cf87
......@@ -262,7 +262,7 @@ SocketType = socket
_GLOBAL_DEFAULT_TIMEOUT = object()
def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT):
def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, source_address=None):
# This is copied directly from Python's implementation.
msg = "getaddrinfo returns an empty list"
host, port = address
......@@ -273,6 +273,8 @@ def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT):
sock = socket(af, socktype, proto)
if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
if source_address:
sock.bind(source_address)
sock.connect(sa)
return sock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment