Merge pull request #600 from deavmi/patch-1

Determine AF FAMILY from getaddrinfo BEFORE socket ctor
This commit is contained in:
markqvist 2024-11-20 14:28:34 +01:00 committed by GitHub
commit 4284084fef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -200,7 +200,9 @@ class TCPClientInterface(Interface):
if initial:
RNS.log("Establishing TCP connection for "+str(self)+"...", RNS.LOG_DEBUG)
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
addrInfo=socket.getaddrinfo(self.target_ip, self.target_port)
addrFam=addrInfo[0]
self.socket = socket.socket(addrFam, socket.SOCK_STREAM)
self.socket.settimeout(TCPClientInterface.INITIAL_CONNECT_TIMEOUT)
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.socket.connect((self.target_ip, self.target_port))