code: def is_port_open(port, host="127.0.0.1"):
      
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      try:
          s.connect((host, int(port)))
          s.shutdown(2)
          return True
      except Exception as e:
          return False
docs: Check if a port is open
      :param port:
      :param host:
      :return bool: