From 8da3bdc5117d6fbd2e75f130fbfd2174813a2ee0 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Sat, 30 Jul 2016 09:56:41 +0800 Subject: [PATCH] set KEEPALIVE except windows --- shadowsocks/tcprelay.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index e70de02..968e4d1 100644 --- a/shadowsocks/tcprelay.py +++ b/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 = ''