Don't fail on windows if bonjour is not installed. fixes #3861
socket module doesn't have AI_ADDRCONFIG attribute under windows
This commit is contained in:
parent
edb5910c1d
commit
1a2f60186a
|
@ -58,9 +58,12 @@ class ZeroconfListener(IdleObject):
|
|||
self.caller = conn_holder.caller
|
||||
self.conn_holder = conn_holder
|
||||
|
||||
def bind(self):
|
||||
def bind(self):
|
||||
flags = socket.AI_PASSIVE
|
||||
if hasattr(socket, 'AI_ADDRCONFIG'):
|
||||
flags |= socket.AI_ADDRCONFIG)
|
||||
ai = socket.getaddrinfo(None, self.port, socket.AF_UNSPEC,
|
||||
socket.SOCK_STREAM, 0, socket.AI_PASSIVE | socket.AI_ADDRCONFIG)[0]
|
||||
socket.SOCK_STREAM, 0, flags)[0]
|
||||
self._serv = socket.socket(ai[0], ai[1])
|
||||
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||
|
|
|
@ -246,7 +246,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
|||
self.status = 'offline'
|
||||
self.dispatch('CONNECTION_LOST',
|
||||
(_('Could not connect to "%s"') % self.name,
|
||||
_('Please check if Avahi is installed.')))
|
||||
_('Please check if Avahi or Bonjour is installed.')))
|
||||
self.disconnect()
|
||||
return
|
||||
result = self.connection.connect(show, msg)
|
||||
|
|
|
@ -31,6 +31,8 @@ def test_bonjour():
|
|||
try:
|
||||
import pybonjour
|
||||
except ImportError:
|
||||
return False
|
||||
except WindowsError:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue