端口
端口
端口表示计算机上的一个程序的进程;
- 不同的进程有不同的端口号!用来区分软件!
- 被规定0~65535
- TCP,UDP:65535* 2 tcp: 80,udp: 80, 单个协议下,端口号不能冲突
- 端口分类
- 公有端口0~1023
- HTTP:80
- HTTPS: 443
- FTP∶21
- Telent : 23
- 程序注册端口:1024~~49151,分配用户或者程序
- Tomcat: 8080
- MysQL : 3306
- oracle: 1521
- 动态、私有:49152~~65535
- 公有端口0~1023
netstat -ano #查看所有的端口
netstat -ano/ findstr "5900”#查看指定的端口
tasklist/findstr "8696"”#查看指定端口的进程
ctrl+ shift + ESC
package Liu.IP;
import java.net.InetSocketAddress;
public class TestPort {
public static void main(String[] args) {
InetSocketAddress socketAddress1 = new InetSocketAddress("127.0.0.1", 8080);
InetSocketAddress socketAddress2 = new InetSocketAddress("localhost", 8080);
System.out.println(socketAddress1);
System.out.println(socketAddress2);
System.out.println(socketAddress1.getAddress());//
System.out.println(socketAddress1.getHostName());//地址
System.out.println(socketAddress1.getPort());//端口
}
}