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());
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义