Three-time handshake process
First time
First handshake: When a connection is established, the client sends a SYN packet (SYN=J) to the server and enters the syn_sent state, waiting for the server to confirm; SYN: Synchronous sequence Number (Synchronize Sequence Numbers).
Second time
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 time
Third handshake: The client receives the server's Syn+ack packet, sends the acknowledgment packet ack (ACK=K+1) to the server, and the packet is sent, the client and the server enter the established (TCP connection succeeded) State and complete the three handshake.
The connection process is similar to the following:
"I want to send you the data?" 」
"All right, I'm ready, right?" 」
"ok I want to send you data, you are ready to receive. 」
And then it's on the chatter.
#
The difference between TCP and UDP
1. Connection-based and no-connection
2. Requirements for system resources (more TCP, less UDP)
3.UDP program structure is relatively simple
4. Stream mode and datagram mode
5.TCP guarantees data correctness, UDP may drop packets, TCP guarantees data order, UDP is not guaranteed.
ios-Network access principle and the difference between TCP and UDP