From 4fe6bba4c4f5bd3485add7d5cc846e2f59b879bc Mon Sep 17 00:00:00 2001 From: j Date: Fri, 5 Sep 2014 18:32:08 +0200 Subject: [PATCH] reuse port --- peerlink/localnodes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/peerlink/localnodes.py b/peerlink/localnodes.py index cc0c483..d53e88e 100644 --- a/peerlink/localnodes.py +++ b/peerlink/localnodes.py @@ -141,6 +141,7 @@ class LocalNodes4(LocalNodesBase): def get_socket(self): s = socket.socket (socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) mreq = struct.pack("=4sl", socket.inet_aton(self._BROADCAST), socket.INADDR_ANY) s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) self._socket = s @@ -170,6 +171,7 @@ class LocalNodes6(LocalNodesBase): def get_socket(self): s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) group_bin = socket.inet_pton(socket.AF_INET6, self._BROADCAST) + '\0'*4 s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_JOIN_GROUP, group_bin) self._socket = s