aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Pubnub.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Pubnub.py b/Pubnub.py
index c2d3bd4..74b511f 100644
--- a/Pubnub.py
+++ b/Pubnub.py
@@ -79,7 +79,21 @@ if sys.platform.startswith("linux"):
]
elif sys.platform.startswith("darwin"):
# From /usr/include/netinet/tcp.h
- socket.TCP_KEEPALIVE = 0x10 # idle time used when SO_KEEPALIVE is enabled
+
+ # idle time used when SO_KEEPALIVE is enabled
+ socket.TCP_KEEPALIVE = socket.TCP_KEEPALIVE \
+ if hasattr(socket, 'TCP_KEEPALIVE') \
+ else 0x10
+
+ # interval between keepalives
+ socket.TCP_KEEPINTVL = socket.TCP_KEEPINTVL \
+ if hasattr(socket, 'TCP_KEEPINTVL') \
+ else 0x101
+
+ # number of keepalives before close
+ socket.TCP_KEEPCNT = socket.TCP_KEEPCNT \
+ if hasattr(socket, 'TCP_KEEPCNT') \
+ else 0x102
default_socket_options += [
# Send first keepalive packet 200 seconds after last data packet