code: def get_tcp_server_addresses(tcp_server):
      """
      Get all bound addresses of a started Tornado TCPServer.
      """
      sockets = list(tcp_server._sockets.values())
      if not sockets:
          raise RuntimeError(
              f"TCP Server {tcp_server!r} not started yet?"
          )
  
      def _look_for_family(fam):
          socks = []
          for sock in sockets:
              if sock.family == fam:
                  socks.append(sock)
          return socks
  
      # If listening on both IPv4 and IPv6, prefer IPv4 as defective IPv6
      # is common (e.g. Travis-CI).
      socks = _look_for_family(socket.AF_INET)
      if not socks:
          socks = _look_for_family(socket.AF_INET6)
      if not socks:
          raise RuntimeError("No Internet socket found on TCPServer??")
  
      return [sock.getsockname() for sock in socks]
  
file_path: distributed/distributed/comm/utils.py
imports: from __future__ import annotations
  import logging
  import socket
  import dask
  from dask.utils import parse_bytes
  from distributed import protocol
  from distributed.sizeof import safe_sizeof
  from distributed.utils import get_ip, get_ipv6, nbytes, offload
label_desc: Use image node_id 1 for calling a global function with example usage: get_tcp_server_addresses(tcp_server) and returns: unknown, socks