From 4bf7f3c0ff5158cd178756bc2a414f506fb34e05 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 4 Sep 2014 16:55:02 +0200 Subject: [PATCH] set source_address if not manually specified --- netlib/tcp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/netlib/tcp.py b/netlib/tcp.py index 5ecfca9dc..ede8682ba 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -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: