- 端口
- 1.区分软件
- 2.2个字节0-65535 UDP TCP独立
- 3.同一个协议下端口不能冲突
- 4.定义端口越大越好
- InetSocketAddress
- 1.构造器
- new InetSocketAddress(域名,端口);
- 2.方法
- getAddress()
- getPort():返回端口
cm命令:
netstat -ano :查看所有端口
**netstat -ano|findstr “xxx” :查看指定端口 **
tasklist|findstr “xxx” :查看指定进程
InetSocketAddress socketAddress = new InetSocketAddress("127.0.0.1", 8080);
InetSocketAddress socketAddress2 = new InetSocketAddress("localhost", 9000);
System.out.println(socketAddress.getHostName());
System.out.println(socketAddress.getAddress());
System.out.println(socketAddress2.getAddress());
System.out.println(socketAddress2.getPort());