diff --git a/confluent_server/confluent/discovery/protocols/slp.py b/confluent_server/confluent/discovery/protocols/slp.py index 4fd1391c..a9beda8e 100644 --- a/confluent_server/confluent/discovery/protocols/slp.py +++ b/confluent_server/confluent/discovery/protocols/slp.py @@ -112,7 +112,10 @@ def _parse_slp_packet(packet, peer, rsps, xidmap, defer=None, sock=None): identifier = addr else: probepeer = (peer[0], struct.unpack('H', os.urandom(2))[0] | 1025) + peer[2:] - sock.sendto(b'\x00', probepeer) + try: + sock.sendto(b'\x00', probepeer) + except Exception: + return defer.append((packet, peer)) return if (identifier, parsed['xid']) in rsps: @@ -487,7 +490,10 @@ def snoop(handler, protocol=None): mac = neighutil.get_hwaddr(peer[0]) if not mac: probepeer = (peer[0], struct.unpack('H', os.urandom(2))[0] | 1025) + peer[2:] - s.sendto(b'\x00', probepeer) + try: + s.sendto(b'\x00', probepeer) + except Exception: + continue deferpeers.append(peer) continue process_peer(newmacs, known_peers, peerbymacaddress, peer) diff --git a/confluent_server/confluent/discovery/protocols/ssdp.py b/confluent_server/confluent/discovery/protocols/ssdp.py index 71dee347..f747f0b6 100644 --- a/confluent_server/confluent/discovery/protocols/ssdp.py +++ b/confluent_server/confluent/discovery/protocols/ssdp.py @@ -167,7 +167,10 @@ def snoop(handler, byehandler=None, protocol=None, uuidlookup=None): continue mac = neighutil.get_hwaddr(peer[0]) if not mac: - s.sendto(b'\x00', peer) + try: + s.sendto(b'\x00', peer) + except Exception: + continue deferrednotifies.append((peer, rsp)) continue _process_snoop(peer, rsp, mac, known_peers, newmacs, peerbymacaddress, byehandler, machandlers) @@ -311,8 +314,11 @@ def _find_service(service, target): for s in r: (rsp, peer) = s.recvfrom(9000) if not neighutil.get_hwaddr(peer[0]): + try: + s.sendto(b'\x00', peer) + except Exception: + continue deferparse.append((rsp, peer)) - s.sendto(b'\x00', peer) continue _parse_ssdp(peer, rsp, peerdata) timeout = deadline - util.monotonic_time()