埠
port 埠:埠表示計算機上的一個程式的行程
-
不同的行程有不同的埠號,用來區分軟體,
-
被規定: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
netstat -ano # 查看所有的埠 netstat -ano|findstr "8080" #查看指定的埠 tasklist|findstr "8696" #查看指定埠的行程 Ctrl + Shift + ESC #打開任務管理器快捷鍵
-
-
Socket:套接字
package lesson01; import java.net.InetSocketAddress; /** * Socket:套接字 */ public class TestInetSocketAddress { public static void main(String[] args) { InetSocketAddress socketAddress = new InetSocketAddress("127.0.0.1", 8080); InetSocketAddress localhostAddress = new InetSocketAddress("localhost", 8080); System.out.println(socketAddress); //輸出內容:/127.0.0.1:8080 System.out.println(localhostAddress); //輸出內容:localhost/127.0.0.1:8080 System.out.println(socketAddress.getHostName()); //主機 System.out.println(socketAddress.getAddress()); //地址 System.out.println(socketAddress.getPort()); //埠號 } }
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/223886.html
標籤:Java
