docs: private void resetNextInetSocketAddress(Proxy proxy) throws IOException {
      // Clear the addresses. Necessary if getAllByName() below throws!
      inetSocketAddresses = new ArrayList<>();
  
      String socketHost;
      int socketPort;
      if (proxy.type() == Proxy.Type.DIRECT || proxy.type() == Proxy.Type.SOCKS) {
        socketHost = address.url().host();
        socketPort = address.url().port();
      } else {
        SocketAddress proxyAddress = proxy.address();
        if (!(proxyAddress instanceof InetSocketAddress)) {
          throw new IllegalArgumentException(
              "Proxy.address() is not an " + "InetSocketAddress: " + proxyAddress.getClass());
        }
        InetSocketAddress proxySocketAddress = (InetSocketAddress) proxyAddress;
        socketHost = getHostString(proxySocketAddress);
        socketPort = proxySocketAddress.getPort();
      }
  
      if (socketPort < 1 || socketPort > 65535) {
        throw new SocketException("No route to " + socketHost + ":" + socketPort
            + "; port is out of range");
      }
  
      if (proxy.type() == Proxy.Type.SOCKS) {
        inetSocketAddresses.add(InetSocketAddress.createUnresolved(socketHost, socketPort));
      } else {
        eventListener.dnsStart(call, socketHost);
  
        // Try each address for best behavior in mixed IPv4/IPv6 environments.
        List<InetAddress> addresses = address.dns().lookup(socketHost);
        if (addresses.isEmpty()) {
          throw new UnknownHostException(address.dns() + " returned no addresses for " + socketHost);
        }
  
        eventListener.dnsEnd(call, socketHost, addresses);
  
        for (int i = 0, size = addresses.size(); i < size; i++) {
          InetAddress inetAddress = addresses.get(i);
          inetSocketAddresses.add(new InetSocketAddress(inetAddress, socketPort));
        }
      }
    }