端口port

发布时间 2023-03-22 21:15:32作者: 惊鸿宴远赴人间
package edu.wtbu;

import java.net.InetSocketAddress;

/*
端口:表示计算机上一个程序的进程
1.不同的进程有不同的端口号,用来区分软件
2.被规定:0~65535
3.TCP,UDP:65535*2,单个协议下,端口号不能冲突
4.端口分类:
公有端口:0~1023
HTPP:80
HTPPS:443
FTP:21
Telent:23
程序注册端口:1024~49151,分配用户或者程序
Tomcat:8080
Mysql:3306
Oracle:1521
动态,私有:49152~65525
netstat -ano 查看所有端口
netstat -ano|findstr "5900" 查看指定的端口
tasklist|findstr "14540"
打开任务管理器:Ctrl+shift+Esc或者Ctrl+Alt+del
*/
public class Demo01 {
public static void main(String[] args) {
InetSocketAddress inetSocketAddress1 = new InetSocketAddress("127.0.0.1",8080);
InetSocketAddress inetSocketAddress2 = new InetSocketAddress("localhost",8080);
System.out.println(inetSocketAddress1);
System.out.println(inetSocketAddress2);

System.out.println(inetSocketAddress1.getAddress());
System.out.println(inetSocketAddress1.getHostName());
System.out.println(inetSocketAddress1.getPort());
}
}