Skip to content

Commit

Permalink
Allow broadcast to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Feb 18, 2018
1 parent 62ecc1c commit 8096327
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plugins/AnnounceLocal/BroadcastServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ def broadcast(self, message, port=None):
self.log.debug("Broadcast using ips %s on port %s: %s" % (my_ips, port, message["cmd"]))

for my_ip in my_ips:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.bind((my_ip, 0))
sock.sendto(msgpack.packb(message), addr)
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.bind((my_ip, 0))
sock.sendto(msgpack.packb(message), addr)
except Exception as err:
self.log.warning("Error sending broadcast using ip %s: %s" % (my_ip, err))

def handleMessage(self, addr, message):
self.log.debug("Got from %s: %s" % (addr, message["cmd"]))
Expand Down

0 comments on commit 8096327

Please sign in to comment.