端口表示计算机上的一个程序的进程:
公有端口 0~1023
程序注册端口:1024~49151,分配给用户或者程序
动态,私有:49152~65535
netstat -ano #查看所有的端口
netstat -ano|findstr '80' #查看指定的端口
tasklist|findstr "5988" #查看指定端口的进程
ctrl+shift+esc
package top.ltyzqhh.Net;
import java.net.InetSocketAddress;
public class TestInetSocketAddress {
public static void main(String[] args) {
InetSocketAddress socketAddress = new InetSocketAddress("127.0.0.1", 8080);
System.out.println(socketAddress);
System.out.println(socketAddress.getAddress());
System.out.println(socketAddress.getHostName());//地址
System.out.println(socketAddress.getPort());//端口
}
}