From c013386ecb3a77f10882e9828af1086748383c57 Mon Sep 17 00:00:00 2001 From: Brian May Date: Mon, 15 Sep 2014 14:32:59 +1000 Subject: [PATCH] If IPv4 bind but IPv6 succeeds don't error. --- src/client.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client.py b/src/client.py index ef4920a..3be0df2 100644 --- a/src/client.py +++ b/src/client.py @@ -209,7 +209,15 @@ class MultiListener: if self.v6: self.v6.listen(backlog) if self.v4: - self.v4.listen(backlog) + try: + self.v4.listen(backlog) + except socket.error, e: + # on some systems v4 bind will fail if the v6 suceeded, + # in this case the v6 socket will receive v4 too. + if e.errno == errno.EADDRINUSE and self.v6: + self.v4 = None + else: + raise e def bind(self, address_v6, address_v4): if address_v6 and self.v6: