网络通信三要素
IP地址
- IP域名->DNS域名解析
- 公网IP、内网IP 192.168
- 本机IP 127.0.0.1 localhost
- ipconfig
- ipconfig /all 物理地址
- ping ip
端口
通信协议
InetAddress
- public static InetAddress getLocalHost() throw UnknownException
- public String getHostName()
- public String getHostAddress()
- public static InetAddress getByName(String host) throw UnknowHostException
- publci boolean isReachable(int timeout) throws IOException
端口
0-65535
HTTP 80 FTP 21
- 周知端口 0-1023
- 注册端口 1024-49151
- 动态端口 49152-65535
协议
- UDP:自己的IP和端口,对方的IP和端口,一包数据
- TCP:三次握手建立连接,可靠连接(全双工),四次握手断开连接