Browse Source

set KEEPALIVE except windows

dev
BreakWa11 8 years ago
parent
commit
8da3bdc511
  1. 2
      shadowsocks/tcprelay.py

2
shadowsocks/tcprelay.py

@ -26,6 +26,7 @@ import logging
import binascii
import traceback
import random
import platform
from shadowsocks import encrypt, obfs, eventloop, shell, common
from shadowsocks.common import pre_parse_header, parse_header
@ -564,6 +565,7 @@ class TCPRelayHandler(object):
else:
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
remote_sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
if platform.system() != 'Windows':
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, 120)
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, 20)
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, 5)

Loading…
Cancel
Save