code: def connect_logger(utils_package_object, host, port):
      """
      This method starts a simple server which listens on a port for a
      client to connect and start writing messages. Whenever a message
      is received, it is written to sys.stderr. The server is run in
      a daemon thread from the caller, which is killed when the caller
      thread dies.
  
      If the socket is in use, then the server tries to listen on the
      next port (port + 1). After 25 tries, it gives up.
  
      :param str host: Hostname for server.
      :param int port: Port to listen on.
      """
      server = None
      tries = 0
      max_tries = 25
      while not server:
          try:
              server = SimpleServer((host, port), LoggingTCPHandler)
          except socket.error:
              port += 1
              tries += 1
  
              if tries >= max_tries:
                  sys.stderr.write(
                      "WARNING: Could not find a free port for logger, maximum retries {} exceeded.".format(
                          max_tries
                      )
                  )
                  return
  
      t = Thread(target=server.serve_forever, args=())
  
      # The thread should be a daemon so that it shuts down when the parent thread is killed
      t.daemon = True
  
      t.start()
      utils_package_object.addSocketAppender(host, port)
  
imports: from typing import Mapping, Set, Tuple
  import abc
  import socket
  import socketserver
  import sys
  from threading import Thread
  import orjson
  import requests
  import py4j
  from py4j.java_gateway import JavaObject, JVMView
  import hail
  from hail.expr import construct_expr
  from hail.ir import JavaIR
  from hail.utils.java import FatalError, Env, scala_package_object
  from .backend import ActionTag, Backend, fatal_error_from_java_error_triplet
  from ..hail_logging import Logger
  import http.client
label_desc: Use image node_id 4 for calling a global function with example usage: connect_logger(utils_package_object, host, port) without return types