What is the difference between TCP and UDP?
sobes.tech AI
Answer from AI
TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are transport protocols that differ in several key parameters:
-
Reliability: TCP provides reliable data delivery — it guarantees that packets will arrive in the correct order and without loss. UDP does not guarantee delivery or order; packets may be lost or arrive out of order.
-
Connection establishment: TCP establishes a connection through a three-way handshake before data transfer. UDP is connectionless; data is sent immediately.
-
Speed: UDP is faster because it does not spend time on connection setup and acknowledgments.
-
Usage: TCP is suitable for applications where data integrity is important (e.g., web, email, files). UDP is used for applications where speed is crucial and some data loss is acceptable (streaming, gaming, VoIP).
Example: TCP is used when loading a web page, while UDP is used during video calls.