Minor TCP optimization

This commit is contained in:
Miroslav Stampar
2018-12-17 14:19:59 +01:00
parent 4ba9e9397c
commit c497aa98ed
3 changed files with 9 additions and 3 deletions

View File

@@ -893,6 +893,12 @@ def _setSocketPreConnect():
family, type, proto, address = key
s = socket.socket(family, type, proto)
s._connect(address)
try:
if type == socket.SOCK_STREAM:
# Reference: https://www.techrepublic.com/article/tcp-ip-options-for-high-performance-data-transmission/
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
except:
pass
with kb.locks.socket:
socket._ready[key].append((s._sock, time.time()))
except KeyboardInterrupt: