JavaTM Platform
Standard Ed. 6

类 java.net.UnknownHostException
的使用

使用 UnknownHostException 的软件包
java.net 为实现网络应用程序提供类。 
javax.net 提供用于网络应用程序的类。 
javax.net.ssl 提供用于安全套接字包的类。 
 

java.net 中 UnknownHostException 的使用
 

抛出 UnknownHostException 的 java.net 中的方法
static InetAddress[] InetAddress.getAllByName(String host)
          在给定主机名的情况下,根据系统上配置的名称服务返回其 IP 地址所组成的数组。
static InetAddress InetAddress.getByAddress(byte[] addr)
          在给定原始 IP 地址的情况下,返回 InetAddress 对象。
static InetAddress InetAddress.getByAddress(String host, byte[] addr)
          根据提供的主机名和 IP 地址创建 InetAddress。
static Inet6Address Inet6Address.getByAddress(String host, byte[] addr, int scope_id)
          完全按照 InetAddress.getByAddress(String,byte[]) 的方式创建 Inet6Address,唯一的不同是将 IPv6 scope_id 设置为给定的数字值。
static Inet6Address Inet6Address.getByAddress(String host, byte[] addr, NetworkInterface nif)
          完全按照 InetAddress.getByAddress(String,byte[]) 的方式创建 Inet6Address,唯一的不同是将 IPv6 scope_id 设置为与在 addr 中指定地址类型的给定接口相对应的值。
static InetAddress InetAddress.getByName(String host)
          在给定主机名的情况下确定主机的 IP 地址。
static InetAddress InetAddress.getLocalHost()
          返回本地主机。
 

抛出 UnknownHostException 的 java.net 中的构造方法
Socket(String host, int port)
          创建一个流套接字并将其连接到指定主机上的指定端口号。
 

javax.net 中 UnknownHostException 的使用
 

抛出 UnknownHostException 的 javax.net 中的方法
abstract  Socket SocketFactory.createSocket(String host, int port)
          创建一个套接字并把它连接到指定远程主机上的指定远程端口。
abstract  Socket SocketFactory.createSocket(String host, int port, InetAddress localHost, int localPort)
          创建一个套接字并把它连接到指定远程主机上的指定远程端口。
 

javax.net.ssl 中 UnknownHostException 的使用
 

抛出 UnknownHostException 的 javax.net.ssl 中的构造方法
SSLSocket(String host, int port)
          仅供子类使用。
SSLSocket(String host, int port, InetAddress clientAddress, int clientPort)
          仅供子类使用。
 


JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。