code: static String getHostString(InetSocketAddress socketAddress) {
      InetAddress address = socketAddress.getAddress();
      if (address == null) {
        // The InetSocketAddress was specified with a string (either a numeric IP or a host name). If
        // it is a name, all IPs for that name should be tried. If it is an IP address, only that IP
        // address should be tried.
        return socketAddress.getHostName();
      }
      // The InetSocketAddress has a specific address: we should only try that address. Therefore we
      // return the address and ignore any host name that may be available.
      return address.getHostAddress();
    }
docs: Visible for testing