端口:
区分不同软件,3个字节,0-65535
同一个协议下端口不能相同,不同协议可以
使用InetSocketAddress实现类
构造器方法:
InetSocketAddress socketaddress=new InetSocketAddress(ip地址/域名,端口号);
常用方法:
.getHostName();
.getAddress();
.getPort();

public class http {

public static void main(String[]args) throws UnknownHostException
{
    InetSocketAddress socketaddress=new InetSocketAddress( "127.0.0.1", 8080);
    InetSocketAddress socketaddress2=new InetSocketAddress("localhost",9000);
    System.out.println(socketaddress.getHostName());//获取本机名
    System.out.println(socketaddress2.getAddress());//获取本机地址和域名
    System.out.println(socketaddress.getPort());//得到端口名

}
}