Browse Source

set KEEPALIVE except windows

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

8
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,9 +565,10 @@ class TCPRelayHandler(object):
else:
remote_sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
remote_sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
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)
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)
if not self._is_local:
bind_addr = ''

Loading…
Cancel
Save