1.1 计算机网络
1.2 网络通信的要素
1.3 ip
常用方法部分了解
package com.kuang.lesson01;
import java.net.InetAddress;
import java.net.UnknownHostException;
//测试IP
public class TestInetAddress {
public static void main(String[] args) {
try {
//InetAddress里面没有构造器和字段,所以不能new 只能通过静态方法返回过来
InetAddress inetAddress1 = InetAddress.getByName("127.0.0.1");
System.out.println(inetAddress1);
InetAddress inetAddress2 = InetAddress.getByName("localhost");//不同方式获得本机ip
System.out.println(inetAddress2);
InetAddress inetAddress3 = InetAddress.getLocalHost();
System.out.println(inetAddress3);
//查询网站ip地址
InetAddress inetAddress4 = InetAddress.getByName("www.baidu.com");
System.out.println(inetAddress4);
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
/127.0.0.1
localhost/127.0.0.1
DESKTOP-2GITFTM/192.168.3.30
www.baidu.com/110.242.68.3
1.4 端口Port
1.5 通信协议
计算机之间如何交流
网络通信协议:针对网络产生一种协议
1.6 TCP实现聊天
1.6.1 TCP文件上传
1.7 UDP
1.7.1 UDP消息发送
被挡住那里是接收数据包