A minor optimization to prevent possible host resolution when inspecting a InetSocketAddress for a hostname....

@param remoteAddress
@return
@throws IOException
510543
private String resolveHostName(InetSocketAddress remoteAddress) {
        String hostString = null;
        try {
            hostString = (String) getHostMethod.invoke(remoteAddress, new Object[]{});
        } catch (InvocationTargetException ite) {
            throw new RuntimeException("Expecting InetSocketAddress to have a package scoped \"getHostString\" method which returns a String and takes no input");
        } catch (IllegalAccessException iae) {
            throw new RuntimeException("Expecting InetSocketAddress to have a package scoped \"getHostString\" method which returns a String and takes no input");
        }
        return hostString;
    }
580685
protected CompletableFuture<List<String>> remoteWebSocketAddresses(@RpcTargetAddress InetSocketAddress targetAddress, Serializable userid) {
        if (remoteNode == null) return CompletableFuture.completedFuture(null);
        try {
            return remoteNode.getWebSocketAddresses(targetAddress, userid);
        } catch (Exception e) {
            logger.log(Level.WARNING, "remote " + targetAddress + " websocket getOnlineRemoteAddresses error", e);
            return CompletableFuture.completedFuture(null);
        }
    }
260726
public void setInetAddress(InetSocketAddress address) {
		this.value = address.getAddress();
		this.type = AttributeType.INET_ADDRESS;
		this.assigned = this.value != null;
	}
761519
private boolean open() throws IOException
    {
        assert (fd == null);

        //  Resolve the address
        if (addr == null) {
            throw new IOException("Null address");
        }

        addr.resolve(options.ipv6);

        Address.IZAddress resolved = addr.resolved();
        if (resolved == null) {
            throw new IOException("Address not resolved");
        }

        SocketAddress sa = resolved.address();
        if (sa == null) {
            throw new IOException("Socket address not resolved");
        }

        //  Create the socket.
        if (options.selectorChooser == null) {
            fd = SocketChannel.open();
        }
        else {
            fd = options.selectorChooser.choose(resolved, options).openSocketChannel();
        }

        // On some systems, IPv4 mapping in IPv6 sockets is disabled by default.
        // Switch it on in such cases.
        // The method enableIpv4Mapping is empty. Still to be written
        if (resolved.family() == StandardProtocolFamily.INET6) {
            TcpUtils.enableIpv4Mapping(fd);
        }

        // Set the socket to non-blocking mode so that we get async connect().
        TcpUtils.unblockSocket(fd);

        //  Set the socket buffer limits for the underlying socket.
        if (options.sndbuf != 0) {
            TcpUtils.setTcpSendBuffer(fd, options.sndbuf);
        }
        if (options.rcvbuf != 0) {
            TcpUtils.setTcpReceiveBuffer(fd, options.rcvbuf);
        }

        // Set the IP Type-Of-Service priority for this socket
        if (options.tos != 0) {
            TcpUtils.setIpTypeOfService(fd, options.tos);
        }

        // TODO V4 Set a source address for conversations
        if (resolved.sourceAddress() != null) {
            //            SocketChannel bind = channel.bind(resolved.sourceAddress());
            //            if (bind == null) {
            //                return false;
            //            }
        }

        //  Connect to the remote peer.
        boolean rc;
        try {
            rc = fd.connect(sa);
            if (rc) {
                //  Connect was successful immediately.
            }
            else {
                //  Translate error codes indicating asynchronous connect has been
                //  launched to a uniform EINPROGRESS.
                errno.set(ZError.EINPROGRESS);
            }
        }
        catch (IllegalArgumentException e) {
            // this will happen if sa is bad.  Address validation is not documented but
            // I've found that IAE is thrown in openjdk as well as on android.
            throw new IOException(e.getMessage(), e);
        }

        return rc;

    }
293532
@Override
  public InetSocketAddress ipRemote()
  {
    Socket s = getSocket();
    
    if (s != null) {
      return (InetSocketAddress) s.getRemoteSocketAddress();
    }
    else {
      return null;
    }
  }
521007
public static InetAddress resolveLocalNet(String host, 
                                              String netInterface) 
    	throws IOException {
        
        return resolveLocalNet(host, netInterface, null);
    }
727751
@Nullable
  public static InetSocketAddress parseInetSocketAddress(String address) throws IOException {
    if (address == null) {
      return null;
    }
    String[] strArr = address.split(":");
    if (strArr.length != 2) {
      throw new IOException("Invalid InetSocketAddress " + address);
    }
    return new InetSocketAddress(strArr[0], Integer.parseInt(strArr[1]));
  }
348098
public RpcInternalContext setRemoteAddress(String host, int port) {
        if (host == null) {
            return this;
        }
        if (port < 0 || port > 0xFFFF) {
            port = 0;
        }
        // 提前检查是否为空，防止createUnresolved抛出异常，损耗性能
        this.remoteAddress = InetSocketAddress.createUnresolved(host, port);
        return this;
    }
1361187
@Override
  public InetAddress addressLocal()
  {
    SocketChannel s = _channel;
    
    if (s != null) {
      try {
        InetSocketAddress addr = (InetSocketAddress) s.getLocalAddress();
        
        return addr.getAddress();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    else {
      return null;
    }
  }
561203
public static InetSocketAddress parseBindAddress(String bindAddress) {
        Exception cause = null;
        try {
            if (!bindAddress.contains(":")) {
                // port only
                return new InetSocketAddress(Integer.parseInt(bindAddress));
            }
            // Test for network interface syntax
            Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY_PORT);
            Matcher matcher = pattern.matcher(bindAddress);
            if (matcher.find()) {
                return new InetSocketAddress(matcher.group(1), parseInt(matcher.group(2)));
            }

            // host:port (let URI handle it including ipv6)
            String tmpAddress = "scheme://" + bindAddress;
            URI uri = URI.create(tmpAddress);
            if (uri.getPort() != -1) {
                return new InetSocketAddress(uri.getHost(), uri.getPort());
            }
        } catch (Exception e) {
            // Exception handled outside catch
            cause = e;
        }
        throw new IllegalArgumentException(String.format("Bind address \"%s\" should be in "
                + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" "
                + "format.", bindAddress), cause);
    }
1298216
public final B serverAddresses(Iterable<InetSocketAddress> serverAddresses) {
        requireNonNull(serverAddresses, "serverAddresses");
        final DnsServerAddresses addrs = DnsServerAddresses.sequential(serverAddresses);
        serverAddressStreamProvider = hostname -> addrs.stream();
        return self();
    }
592761
@Override
  public void _LocalPeer_removeIPAddress(String ipAddress) throws MBeanException {
    Configuration[] oldIPAddressesConfig = getMutableConfiguration().getChildren(OwnIPAddresses.ordinal());

    Configuration ipAddressToRemove = null;

    List<Configuration> newIPAddressesConfig  = Arrays.asList(oldIPAddressesConfig);
    for (Configuration curIPAddress : newIPAddressesConfig) {
      if (curIPAddress.getStringValue(OwnIPAddress.ordinal(), DEFAULT_STRING).equals(ipAddress)) {
        ipAddressToRemove = curIPAddress;
        break;
      }
    }

    if (ipAddressToRemove != null) {
      newIPAddressesConfig.remove(ipAddressToRemove);

      getMutableConfiguration().setChildren(OwnIPAddresses.ordinal(), (Configuration[]) newIPAddressesConfig.toArray());

      if (logger.isInfoEnabled()) {
        logger.info("Local Peer IP Address " + ipAddress + " successfully added. Restart to Diameter stack is needed to apply changes.");
      }
    }
    else {
      if (logger.isInfoEnabled()) {
        logger.info("Local Peer IP Address " + ipAddress + " not found. No changes were made.");
      }
    }
  }
726472
@Override
  public InetAddress addressRemote()
  {
    SocketChannel s = _channel;
    
    if (s != null) {
      try {
        InetSocketAddress addr = (InetSocketAddress) s.getRemoteAddress();
        
        return addr.getAddress();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    else {
      return null;
    }
  }
914698
public void setInetAddress(String hostname) {
		this.type = AttributeType.INET_ADDRESS;
		try {
			this.value = InetAddress.getByName(hostname);
		} catch (Throwable exception) {
			this.value = null;
		}
		this.assigned = this.value != null;
	}
1129043
public InetSocketAddress getSocketAddr(
			String name, String defaultAddress, int defaultPort) {
		final String address = getTrimmed(name, defaultAddress);
		return NetUtils.createSocketAddr(address, defaultPort, name);
	}
1278914
protected AddressResolver<InetSocketAddress> newAddressResolver(EventLoop eventLoop,
                                                                    NameResolver<InetAddress> resolver)
            throws Exception {
        return new InetSocketAddressResolver(eventLoop, resolver);
    }
337533
public InetSocketAddress getRemoteAddress()
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getRemoteAddress");
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getRemoteAddress","rc="+remoteAddress);
      return remoteAddress;
   }