code: def tcp_server(tcp_addr, settings):
      """Start up the tcp server, send 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
      )
      sock.bind(tcp_addr)
      sock.listen(1)
      logging.info("Waiting for connection on %s", tcp_addr)
      conn, addr = sock.accept()
      logging.info("Accepted connection from %s", Addr(*addr[:2]))
  
      # Send map_data independently for py2/3 and json encoding reasons.
      write_tcp(conn, settings["map_data"])
      send_settings = {
          k: v for k, v in settings.items() if k != "map_data"
      }
      logging.debug("settings: %s", send_settings)
      write_tcp(conn, json.dumps(send_settings).encode())
      return conn
  
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 3 for calling a global function with example usage: tcp_server(tcp_addr, settings) and returns: conn