[] The three elements of network programming

IP Address: InetAddress
Identifying the network device, easy to remember, the host name is available
The port number
Identifies the logical address, the process used to identify the different processes
Transfer Protocol
Rules of communication
Common protocols: TCP, UDP
IP Address:
Uniquely identifies your computer. In order to facilitate our acquisition and operation of the IP address, java provides a class InetAddress for our use.
 
A: The so-called IP address to each host is connected to the Internet is assigned a 32bit address. In accordance with TCP / IP predetermined, the IP address is represented in binary, each IP address length 32bit, converted into bit byte is 4 bytes.
For example in the form of a binary IP address is "00001010000000000000000000000001", so long address, people deal with it too strenuous. In order to facilitate the use of people, IP addresses are often written in decimal form, using an intermediate symbols. "" Separate the different bytes. So, the above IP address can be represented as "10.0.0.1". IP address This notation is called "dotted decimal notation", which is obviously much easier to remember than 1 and 0.
 
B: consisting of IP addresses
Address = IP address of the host network number +
Class A IP addresses: the first number is the network number, the remaining three slot number for the local computer number
Class B IP ADDRESS: Sec number is the network number, the remaining number Sec number for the local computer
Class C IP Address: The first three numbers for the network segment number, the rest of the period the number of numbers for the local computer
 
Special Address:
Loopback address 127.0.0.1, a network can be used to test whether the machine in question. Ping 127.0.0.1
 
DOS command ipconfig: Check the local IP address
 
xxx.xxx.xxx.0 network address
xxx.xxx.xxx.255 broadcast address
 
A class 1.0.0.1 --- 127.255.255.254
(1) 10.XXX is a private address (private address is not used on the Internet, and is used in local area network address)
(2) 127.XXX is reserved addresses, used cycle testing.
B 类128.0.0.1---191.255.255.254,172.16.0.0---172.31.255.255 是私有地址。169.254.X.X 是保留地址。
C 类 192.0.0.1---223.255.255.254
192.168.X.X 是私有地址(在互联网上不适用,在局域网中用)
D 类224.0.0.1---239.255.255.254
E 类 240.0.0.1---247.255.255.254
 
端口号:
正在运行程序的标识
物理端口:网卡口
逻辑端口:我们指的就是逻辑端口
A:每个网络程序都会至少有一个逻辑端口
B:用于标识进程的逻辑地址,不同进程的标识
C:有效端口:0~65535,其中 0~1024 系统使用或保留端口。通过 360 可以查看端口号
 
协议:
通信的规则。
UDP
将数据源和目的封装成数据包中,不需要建立连接;每个数据报的大小在限制在 64k;
因无连接,是不可靠协议;不需要建立连接,速度快。
例如:聊天留言,在线视频,视频会议,发短信。
TCP
建立连接,形成传输数据的通道;在连接中进行大数据量传输;
通过三次握手完成连接,是可靠协议;
必须建立连接,效率会稍低
例如:下载,打电话,QQ 聊天(你在线吗,在线,就回应下,就开始聊天了)

Guess you like

Origin www.cnblogs.com/zuixinxian/p/11275363.html