Respond to all broadcasts at once, not just to one.

This commit is contained in:
Charles Haley 2012-08-28 10:22:43 +02:00
parent 4ce9dd36fa
commit 15749dc4d7

View File

@ -579,16 +579,20 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
self._close_device_socket()
return (self.is_connected, self)
if getattr(self, 'broadcast_socket', None) is not None:
ans = select.select((self.broadcast_socket,), (), (), 0)
if len(ans[0]) > 0:
try:
packet = self.broadcast_socket.recvfrom(100)
remote = packet[1]
message = str(socket.gethostname().partition('.')[0] + '|') + str(self.port)
self._debug('received broadcast', packet, message)
self.broadcast_socket.sendto(message, remote)
except:
traceback.print_exc()
while True:
ans = select.select((self.broadcast_socket,), (), (), 0)
if len(ans[0]) > 0:
try:
packet = self.broadcast_socket.recvfrom(100)
remote = packet[1]
message = str(socket.gethostname().partition('.')[0]
+ '|') + str(self.port)
self._debug('received broadcast', packet, message)
self.broadcast_socket.sendto(message, remote)
except:
pass
else:
break
if getattr(self, 'listen_socket', None) is not None:
ans = select.select((self.listen_socket,), (), (), 0)