Check if the platform is macOS before trying to set a non-exported

TCP_KEEPIDLE option
This commit is contained in:
Leon Jacobs 2016-11-02 08:34:53 +02:00
parent 4a7499df03
commit bcac8c4166

View file

@ -140,7 +140,9 @@ def ConnectToTarget():
s.setsockopt(SOL_SOCKET, SO_KEEPALIVE, 1)
s.setsockopt(IPPROTO_TCP, TCP_KEEPCNT, 15)
s.setsockopt(IPPROTO_TCP, TCP_KEEPINTVL, 5)
s.setsockopt(IPPROTO_TCP, TCP_KEEPIDLE, 5)
# macOS does not have TCP_KEEPIDLE
if sys.platform != 'darwin':
s.setsockopt(IPPROTO_TCP, TCP_KEEPIDLE, 5)
s.connect(Host)
return s
except: