class_docstr: Auto-discovery service class
class_docstr_tok: ["Auto-discovery","service","class"]
docstr: Listens for broadcasts from other clients/servers
docstr_tok: ["Listens","for","broadcasts","from","other","clients\/servers"]
code: def listen(self):
      """Listens for broadcasts from other clients/servers"""
      self.base.logger.debug("Listening (%s, %i)" % self.interface_addr)
      self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
      self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
      self.socket.settimeout(5)
      self.socket.bind(self.interface_addr)
  
      ppc.start_thread("broadcast", self.broadcast)
  
      while True:
          try:
              if self.base._exiting:
                  return
              message, (host, port) = self.socket.recvfrom(1024)
              message = ppc.str_(message)
              remote_address = (host, self.broadcast_addr[1])
              hostid = host + ":" + str(self.broadcast_addr[1])
              self.base.logger.debug(
                  "Discovered host (%s, %i) message=%c"
                  % (remote_address + (message[0],))
              )
              if (
                  not self.base.autopp_list.get(hostid, 0)
                  and self.isclient
                  and message[0] == "S"
              ):
                  self.base.logger.debug(
                      "Connecting to host %s" % (hostid,)
                  )
                  ppc.start_thread(
                      "ppauto_connect1",
                      self.base.connect1,
                      remote_address + (False,),
                  )
              if not self.isclient and message[0] == "C":
                  self.base.logger.debug(
                      "Replying to host %s" % (hostid,)
                  )
                  self.bsocket.sendto(ppc.b_("S"), self.broadcast_addr)
          except socket.timeout:
              pass
          except:
              self.base.logger.error(
                  "An error has occured during execution of "
                  "Discover.listen"
              )
              sys.excepthook(*sys.exc_info())
  
file_path: ppft/ppft/auto.py
imports: import socket
  import sys
  import time
  import threading
  from .None import common
label_desc: Use image node_id 4 for calling the Discover obj's underlying member method code with example usage: obj.listen() without return types