Recently, the network protocols have been a learning, macro-awareness of the harvest.
The network is divided into the physical layer, the data link layer, the network layer, the transport layer, the conversation layer, the presentation layer and the application layer. Reference
The IP protocol corresponds to the network layer,
The TCP/UDP protocol corresponds to the transport layer,
The HTTP protocol corresponds to the application layer,
The socket is the encapsulation and application of TCP/IP protocol.
Three-time handshake for TCP connections:
First handshake: The client sends a SYN packet (SYN=J) to the server and enters the Syn_send state, waiting for the server to confirm;
Second handshake: The server receives the SYN packet, it must confirm the customer's SYN (ACK=J+1), and also send itself a SYN packet (syn=k), that is, the Syn+ack packet, when the server enters the SYN_RECV state;
Third handshake: The client receives the server's Syn+ack packet, sends the acknowledgment packet ack (ACK=K+1) to the server, the packet is sent, the client and the server enter the established state, and the handshake is completed three times.
The data is not included in the packet that is delivered during the handshake, and the client and server formally begin transmitting the data after the three handshake is complete.
Both the server and the client can initiate a request to disconnect the TCP connection when the connection is disconnected, and the disconnection process requires a "four-time handshake"
TCP is a link-oriented, although the insecure nature of the network determines how many times the handshake can not guarantee the reliability of the connection,
However, the three-time handshake of TCP ensures the reliability of the connection at least (in fact, to a large extent);
While UDP is not connection-oriented, UDP transmits data before the connection with the other, docking received data does not send a confirmation signal,
The sender does not know whether the data will be received correctly, of course, there is no need to resend, so that UDP is a non-connected, unreliable data transfer Protocol
Also due to the above characteristics, so that the cost of UDP smaller data transmission rate is higher, because there is no need to send and receive data confirmation, so UDP real-time better.
HTTP
The port number for the HTTP default port number is 80,https 443
The HTTP protocol is always a client-initiated request, and the server echoes the response. See:
This limits the use of the HTTP protocol, which cannot be implemented when the client does not initiate a request, the server pushes the message to the client.
The HTTP protocol is a stateless protocol, and there is no correspondence between this request and the last request of the same client.
Tcp,udp,http,ip,socket