From 5f37bf3eef58a8d63fc7844aae0f69ff36952cc9 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Tue, 3 Oct 2017 14:31:16 +0200 Subject: [PATCH] Enable TCP_NODELAY if supported --- src/Connection/Connection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Connection/Connection.py b/src/Connection/Connection.py index db874839..78b1ed1a 100644 --- a/src/Connection/Connection.py +++ b/src/Connection/Connection.py @@ -105,6 +105,10 @@ class Connection(object): self.sock = self.server.tor_manager.createSocket(self.ip, self.port) else: self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + if "TCP_NODELAY" in dir(socket): + self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + self.sock.connect((self.ip, int(self.port))) # Implicit SSL @@ -123,6 +127,10 @@ class Connection(object): # Handle incoming connection def handleIncomingConnection(self, sock): self.log("Incoming connection...") + + if "TCP_NODELAY" in dir(socket): + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + self.type = "in" if self.ip not in config.ip_local: # Clearnet: Check implicit SSL try: