Some of the answers collected online:
The connection was maintained on state, and I understood so
is actually maintaining a variable on both the client and server side, this variable maintains the current state of data transmission, such as what is being transmitted, what data is to be transmitted next, and so on, and so on, it's not really what we think is really connected to both ends, because there's a network cable for either connection or no connection. (excluding wireless networks), so the connection is not really something to connect them, the real meaning is what I said above, both sides maintain a state variable.
UDP traffic has four parameters: source IP, source port, destination IP, and destination port. TCP traffic has at least six parameters: source IP, source port, destination IP and destination port, and serial number and answer number.
Serial number and answer number are the specific parameters of TCP communication, TCP communication uses serial number and answer number to maintain and confirm the correlation and correctness of data, is determined in three times handshake, incorrect serial number and answer number will cause not normal communication. Therefore, the connection concept of TCP connection can be easily understood as compared with UDP communication, the serial number and answer number are used to determine the connection characteristics between each other to ensure the correctness of data transmission.
TCP is reliable, connection-oriented and UDP is not reliable, non-connection-oriented, UDP header length far less than the TCP header length. TCP uses three basic mechanisms to implement connection-oriented services: 1 uses serial numbers for labeling, so that TCP receive services can correct the sequence of messages before the data is passed to the destination, and 2 TCP uses confirmation, checksum, and timer systems to provide reliability. 3 TCP attaches a header to the application-layer data, and the header includes the serial Number field and other necessary information about these mechanisms, such as the address field called the port number, which identifies the source point and target application of the data.
I remember the book I read as if UDP sent the package is no matter, the other side will not answer whether received. When TCP sends a packet, the other person responds with a complete receipt.
You can take a similar operation to create a TCP connection at the time of the contract, send a message, then give an ACK, and then send a message to send an ACK, so that the success of sending.
Through the simplest retransmission confirmation can achieve the effect of QQ now, simply said that the sender has been sending data until received feedback from the receiver and then stop.