Set socket options

This commit is contained in:
Mark Qvist 2023-11-05 22:57:03 +01:00
parent cd9e23f2de
commit 7a6ed68482
2 changed files with 5 additions and 0 deletions

View File

@ -78,6 +78,7 @@ class LocalClientInterface(Interface):
self.target_ip = None self.target_ip = None
self.target_port = None self.target_port = None
self.socket = connected_socket self.socket = connected_socket
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.is_connected_to_shared_instance = False self.is_connected_to_shared_instance = False
@ -108,6 +109,7 @@ class LocalClientInterface(Interface):
def connect(self): def connect(self):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.socket.connect((self.target_ip, self.target_port)) self.socket.connect((self.target_ip, self.target_port))
self.online = True self.online = True

View File

@ -116,6 +116,8 @@ class TCPClientInterface(Interface):
elif platform.system() == "Darwin": elif platform.system() == "Darwin":
self.set_timeouts_osx() self.set_timeouts_osx()
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
elif target_ip != None and target_port != None: elif target_ip != None and target_port != None:
self.receives = True self.receives = True
self.target_ip = target_ip self.target_ip = target_ip
@ -200,6 +202,7 @@ class TCPClientInterface(Interface):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.settimeout(TCPClientInterface.INITIAL_CONNECT_TIMEOUT) 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)) self.socket.connect((self.target_ip, self.target_port))
self.socket.settimeout(None) self.socket.settimeout(None)
self.online = True self.online = True