code: def tcp_client(tcp_addr):
      """Connect to the tcp server, and return the settings."""
      family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET
      sock = socket.socket(
          family, socket.SOCK_STREAM, socket.IPPROTO_TCP
      )
      for i in range(300):
          logging.info("Connecting to: %s, attempt %d", tcp_addr, i)
          try:
              sock.connect(tcp_addr)
              break
          except socket.error:
              time.sleep(1)
      else:
          sock.connect(
              tcp_addr
          )  # One last try, but don't catch this error.
      logging.info("Connected.")
  
      map_data = read_tcp(sock)
      settings_str = read_tcp(sock)
      if not settings_str:
          raise socket.error("Failed to read")
      settings = json.loads(settings_str.decode())
      logging.info("Got settings. map_name: %s.", settings["map_name"])
      logging.debug("settings: %s", settings)
      settings["map_data"] = map_data
      return sock, settings
  
imports: import binascii
  import collections
  import hashlib
  import json
  import os
  import shutil
  import socket
  import struct
  import subprocess
  import threading
  import time
  from absl import logging
  from pysc2 import run_configs
  from pysc2.env import sc2_env
  from pysc2.lib import features
  from pysc2.lib import run_parallel
  from s2clientprotocol import sc2api_pb2
label_desc: Use image node_id 4 for calling a global function with example usage: tcp_client(tcp_addr) and returns: sock,  settings