Utility function to create an InetSocketAddress that has been resolved.
Retries once and sleeps 100ms between the failure and the retry

@param hostname
@param port
@return InetSocketAddress, may be unresolved if both attempts fail
965709
public static InetSocketAddress createWithResolveRetry(
    String hostname,
    int port
  ) {
    return createWithResolveRetry(
      hostname,
      port,
      DEFAULT_DELAY_MILLIS,
      DEFAULT_MAX_ATTEMPTS
    );
  }
428457
public static QConnectorSync create(final String host, final int port) {
		return create(host, port, true, true);
	}
333090
public static ServerSocketBar createJNI(InetAddress host, int port)
    throws IOException
  {
      return currentFactory().create(host, port, 0, true);
  }
1129043
public InetSocketAddress getSocketAddr(
			String name, String defaultAddress, int defaultPort) {
		final String address = getTrimmed(name, defaultAddress);
		return NetUtils.createSocketAddr(address, defaultPort, name);
	}
230353
@Override
    public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException {
        final SSLSocketFactory factory = sslCtxt.getSocketFactory();
        final SSLSocket ss = (SSLSocket) factory.createSocket(host, port, localHost, localPort);

        ss.setEnabledProtocols(protocols);

        return ss;
    }
771620
public static NetworkPort remotePort(String hostname, int port){
        return new RemoteNetworkPort(hostname, port, NetworkPort.Type.TCP);
    }
750392
public ChannelFuture connect(String inetHost, int inetPort) {
        return connect(InetSocketAddress.createUnresolved(inetHost, inetPort));
    }
968095
public static NetworkPort remoteDatagramPort(String hostname, int port){
        return new RemoteNetworkPort(hostname, port, NetworkPort.Type.UDP);
    }
448751
protected void connect(String host, int port)
        throws UnknownHostException, IOException
    {
        boolean connected = false;
        try {
            InetAddress address = InetAddress.getByName(host);
            this.port = port;
            this.address = address;

            connectToAddress(address, port, timeout);
            connected = true;
        } finally {
            if (!connected) {
                try {
                    close();
                } catch (IOException ioe) {
                    /* Do nothing. If connect threw an exception then
                       it will be passed up the call stack */
                }
            }
        }
    }
893988
private static InetAddress getLocalHostBySocket(InetSocketAddress remoteAddress) {
        InetAddress host = null;
        try {
            // 去连一下远程地址
            Socket socket = new Socket();
            try {
                socket.connect(remoteAddress, 1000);
                // 得到本地地址
                host = socket.getLocalAddress();
            } finally {
                IOUtils.closeQuietly(socket);
            }
        } catch (Exception e) {
            LOGGER.warn("Can not connect to host {}, cause by :{}",
                remoteAddress.toString(), e.getMessage());
        }
        return host;
    }
556994
public static boolean isAddressReachable(String hostname, int port) {
    try (Socket socket = new Socket(hostname, port)) {
      return true;
    } catch (IOException e) {
      return false;
    }
  }
847959
@Override
  public InetSocketAddress lookup(final Identifier id) throws Exception {

    return cache.get(id, new Callable<InetSocketAddress>() {

      @Override
      public InetSocketAddress call() throws Exception {
        final int origRetryCount = NameLookupClient.this.retryCount;
        int retriesLeft = origRetryCount;
        while (true) {
          try {
            return remoteLookup(id);
          } catch (final NamingException e) {
            if (retriesLeft <= 0) {
              throw e;
            } else {
              final int currentRetryTimeout = NameLookupClient.this.retryTimeout
                  * (origRetryCount - retriesLeft + 1);
              LOG.log(Level.WARNING,
                  "Caught Naming Exception while looking up " + id
                      + " with Name Server. Will retry " + retriesLeft
                      + " time(s) after waiting for " + currentRetryTimeout + " msec.");
              Thread.sleep(currentRetryTimeout);
              --retriesLeft;
            }
          }
        }
      }

    });
  }
375048
public static Proxy httpProxy(String host, int port) {
        return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Objects.requireNonNull(host), port));
    }
85457
@Override
  public InetSocketAddress ipRemote()
  {
    if (_ipRemote == null) {
      try {
        _ipRemote = InetSocketAddress.createUnresolved(getLocalHost(),
                                                      portLocal());
      } catch (Exception e) {
        log.log(Level.FINE, e.toString(), e);
      }
    }

    return _ipLocal;
  }
1304616
@Override
	public ServerSocket createServerSocket(int port) throws IOException
    {
    	ServerSocket socket = getSocketFactory().createServerSocket(port,backLog,getListenAddress());
    	if (manageSockets)
    		createdSockets.add(socket);
    	return socket;
    }
362524
public static SocketAddress resolve(InetSocketAddress inetSocketAddress, DnsResolver dnsResolver) {

        try {
            InetAddress inetAddress = dnsResolver.resolve(inetSocketAddress.getHostString())[0];
            return new InetSocketAddress(inetAddress, inetSocketAddress.getPort());
        } catch (UnknownHostException e) {
            return new InetSocketAddress(inetSocketAddress.getHostString(), inetSocketAddress.getPort());
        }

    }
355932
public InetSocketAddress getMulticastSocketAddress() {
        if (multicastAddress == null) {
            throw MESSAGES.noMulticastBinding(name);
        }
        return new InetSocketAddress(multicastAddress, multicastPort);
    }