端口号介绍
- 不同的进程有不同的端口号,用来区分软件的。
- 规定范围为:0-65535
- 同一协议下端口号不能相同,不同协议下可以相同。
- 端口可以分为公有端口和私有端口和程序注册端口。公有端口为0-1023,一般为计算机运行所需的端口,http的端口为80,https端口为443。程序注册端口1023-49151,一般为我们所使用的端口,如tomcat的8080,mysql的3306。私有端口49152-65535。
public class TestInetSocketAddress {
public static void main(String[] args) {
InetSocketAddress localhost = new InetSocketAddress("localhost", 8080);
System.out.println(localhost);
}
}