端口

suaxi
2020-11-20 / 0 评论 / 157 阅读 / 正在检测是否收录...

端口表示计算机上的一个程序进程

  • 不同的进程有不同的端口号,用来区分软件
  • 规定范围0~65535(TCP/UDP的规范是一样的)
  • 单个协议下端口号不能冲突
  • 端口分类:

    • 公有端口0~1023

      • HTTP:80
      • HTTPS:443
      • FTP:21
      • SSH:22
      • Telent:23
    • 程序注册端口:1024~49151,分配给用户或者程序

      • Tomacat:8080
      • MySQL:3306
      • Oracle:1521
      • RDP:3389
    • 动态、私有:49152~65535
netstat -ano #查看所有的端口
netstat -ano|findstr "5900" #查看指定的端口
tasklist|findstr "8696" #查看指定端口的进程
package com.network.lesson01;

import java.net.InetSocketAddress;

/**
 * @Author suaxi
 * @Date 2020/11/20 17:21
 */
public class TestInetSocketAddress {
    public static void main(String[] args) {
        InetSocketAddress inetSocketAddress = new InetSocketAddress("127.0.0.1", 8080);
        System.out.println(inetSocketAddress);


        System.out.println(inetSocketAddress.getAddress());
        System.out.println(inetSocketAddress.getHostName()); //地址
        System.out.println(inetSocketAddress.getPort()); //端口
    }
}
0

评论 (0)

取消