一.InetAddress
1.作用:封装计算机的ip地址和DNS,没有端口
2.方法
getHostAddress(); 返回ip地址
getHostName(); 返回域名/本机为计算机名
InetAddress.getLocalHost();
InetAddress.getByName("ip地址/域名");
二.InetSocketAddress: InetAddress+端口
1.创建对象:
InetSocketAddress(String hostname, int port);
InetSocketAddress(InetAddress add, int port);
*本机为localhost/127.0.0.1
2.方法
getHostName();
InetAddress getAddress();
getPort();