Example #1
0
 // called from deployment cache manager
 private static InetAddress getByName(String host, InetAddress reqAddr)
     throws UnknownHostException {
   return InetAddress.getAllByName(host, reqAddr)[0];
 }
Example #2
0
 /**
  * Determines the IP address of a host, given the host's name.
  *
  * <p>The host name can either be a machine name, such as "<code>java.sun.com</code>", or a
  * textual representation of its IP address. If a literal IP address is supplied, only the
  * validity of the address format is checked.
  *
  * <p>For <code>host</code> specified in literal IPv6 address, either the form defined in RFC 2732
  * or the literal IPv6 address format defined in RFC 2373 is accepted. IPv6 scoped addresses are
  * also supported. See <a href="Inet6Address.html#scoped">here</a> for a description of IPv6
  * scoped addresses.
  *
  * <p>If the host is <tt>null</tt> then an <tt>InetAddress</tt> representing an address of the
  * loopback interface is returned. See <a
  * href="http://www.ietf.org/rfc/rfc3330.txt">RFC&nbsp;3330</a> section&nbsp;2 and <a
  * href="http://www.ietf.org/rfc/rfc2373.txt">RFC&nbsp;2373</a> section&nbsp;2.5.3.
  *
  * @param host the specified host, or <code>null</code>.
  * @return an IP address for the given host name.
  * @exception UnknownHostException if no IP address for the <code>host</code> could be found, or
  *     if a scope_id was specified for a global IPv6 address.
  * @exception SecurityException if a security manager exists and its checkConnect method doesn't
  *     allow the operation
  */
 public static InetAddress getByName(String host) throws UnknownHostException {
   return InetAddress.getAllByName(host)[0];
 }