set source_address if not manually specified

This commit is contained in:
Maximilian Hils 2014-09-04 16:55:02 +02:00
parent ec628bc37d
commit 4bf7f3c0ff

View File

@ -319,6 +319,8 @@ class TCPClient(_Connection):
if self.source_address:
connection.bind(self.source_address())
connection.connect(self.address())
if not self.source_address:
self.source_address = Address(connection.getsockname())
self.rfile = Reader(connection.makefile('rb', self.rbufsize))
self.wfile = Writer(connection.makefile('wb', self.wbufsize))
except (socket.error, IOError), err: