code: def server_thread(sock, handle_conn, quit_event):
      
      log.debug('server thread started')
  
      def accept_connection():
          conn, _ = sock.accept()
          conn.settimeout(None)
          return conn
  
      while True:
          log.debug('waiting for connection on %s', sock.getsockname())
          try:
              conn = retry(accept_connection, socket.timeout, quit_event)
          except StopIteration:
              log.debug('server stopped')
              break
          # Handle connections from SSH concurrently.
          threading.Thread(target=handle_conn,
                           kwargs=dict(conn=conn)).start()
      log.debug('server thread stopped')
docs: Run a server on the specified socket.