网络编程1.4-端口-2022-12-14

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

   - 不同的进程有不同的端口,端口号不能重复,用来区分软件

  - 被规定 0-65535

   - TCP UDP 各为65535, 两个类端口号可以相同

端口分类

    - 公有端口 0-1023

         --- HTTP 80

         --- HTTPS 443

          --- FTP 21

          --- TELENT 23

 

   - 程序注册端口  1014-49151  分配给用户和程序 

         --- tomcat 8080

         --- MySql  3306

         --- Oracle  1521

    - 动态 私有   49152-65535

         DOS命令:netstat - ano

                            netstat - an0 | findstr "8080"

        快捷键:ctrl+Shift+Esc

package com.lr;

import java.net.InetSocketAddress;

public class testSocketDemo {
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(inetSocketAddress2.getPort());
System.out.println(inetSocketAddress2.getAddress());
}

}

 

  

posted @   Rui2022  阅读(92)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示