code: def discover(timeout=DISCOVERY_TIMEOUT):
      
      hosts = {}
      payload = MAGIC + DISCOVERY
      for _ in range(RETRIES):
          _SOCKET.sendto(bytearray(payload), ('255.255.255.255', PORT))
          start = time.time()
          while time.time() < start + timeout:
              for host, data in _BUFFER.copy().items():
                  if not _is_discovery_response(data):
                      continue
                  if host not in hosts:
                      _LOGGER.debug("Discovered device at %s", host)
                      entry = {}
                      entry['mac'] = data[7:13]
                      entry['imac'] = data[19:25]
                      entry['next'] = 0
                      entry['st'] = int(data[-1])
                      entry['time'] = _device_time(data[37:41])
                      entry['serverTime'] = int(time.time())
                      hosts[host] = entry
      return hosts
docs: Discover devices on the local network.
  
      :param timeout: Optional timeout in seconds.
      :returns: Set of discovered host addresses.