Difference Between TCP and UDP
TCP-the transmission control protocol provides connection-oriented and reliable byte stream services. Before the customer and the server exchange data with each other, a TCP connection must be established between the two parties before data can be transmitted. TCP provides timeout resend, discard duplicate data, test data, traffic control, and other functions to ensure data can be transferred from one end to the other.
UDP-the User Datagram Protocol is a simple datagram-oriented transport layer protocol. UDP does not provide reliability. It only sends the data from the application to the IP layer, but it cannot guarantee that the data can reach the destination. Because UDP does not need to establish a connection between the client and the server before transmitting the datagram, and there is no timeout and re-transmission mechanism, the transmission speed is very fast (as3 does not support udp)
Purpose
TCP is generally used for file transmission (ftp http requires high data accuracy, and the speed can be relatively slow), sending or receiving emails (pop imap smtp requires high data accuracy, non-urgent applications ), remote Logon (Telnet SSH has certain requirements on data accuracy and connection concepts). UDP is generally used for Instant Messaging (QQ chat has low requirements on data accuracy and packet loss, but the speed must be fast), online videos (RTSP must be fast to ensure video continuity, but sometimes one image frame is spent, which is acceptable ), network voice calls (VOIP voice packets are generally relatively small and need to be sent at high speed. Occasionally, there is no problem with disconnected or crosstalk.