From a6ee9d509d27001b939b9e6e2c219a7586394ad4 Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Sun, 9 Apr 2017 20:03:23 -0400 Subject: [PATCH] Fix magneticod on macOS. macOS lacks the `TCP_QUICKACK` option. Since this is simply an optimization, we can safely skip it on macOS. --- magneticod/magneticod/bittorrent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/magneticod/magneticod/bittorrent.py b/magneticod/magneticod/bittorrent.py index 63b8995..a3c399b 100644 --- a/magneticod/magneticod/bittorrent.py +++ b/magneticod/magneticod/bittorrent.py @@ -33,7 +33,8 @@ class DisposablePeer: self.__socket.setblocking(False) # To reduce the latency: self.__socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True) - self.__socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK, True) + if hasattr(socket, 'TCP_QUICKACK'): + self.__socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK, True) res = self.__socket.connect_ex(peer_addr) if res != errno.EINPROGRESS: raise ConnectionError()