一、网络的相关概念
 
(一)网络通信
 
 
(二)网络
 
 
(三)ip地址
 
 
(四)ipv4地址分类
 
 
(五)域名
 
 
(六)端口号
 
 
(七)网络通信协议
 
 
(八)网络通信协议
 
 
(九)TCP和UDP
 
 
 
二、InetAddress类
 
(一)相关方法
 
 
package com.hspedu.api;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class API_ {
    public static void main(String[] args) throws UnknownHostException {
        
        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println(localHost);
        
        InetAddress host1 = InetAddress.getByName("LAPTOP-J6E1LFVM");
        System.out.println("host1=" + host1);
        
        InetAddress host2 = InetAddress.getByName("www.baidu.com");
        System.out.println("host2=" + host2);
        
        String hostAddress = host2.getHostAddress();
        System.out.println("host2 对象的ip = " + hostAddress);
        
        String hostName = host2.getHostName();
        System.out.println("host2对应的主机名/域名=" + hostName);
    }
}
 
三、Socket
 
(一)基本介绍
 
 
四、TCP网络通信编程
 
(一)基本介绍
 
 
(二)应用案例1(使用字节流)