What is the difference between TCP and UDP?
EasyConceptTCP & UDP
Answer
TCP (Transmission Control Protocol) is connection-oriented and reliable: it sets up a connection first and guarantees that data arrives complete and in order. UDP (User Datagram Protocol) is connectionless and unreliable: it sends independent messages, called datagrams, with no guarantee of delivery or order.
| TCP | UDP | |
|---|---|---|
| Connection | three-way handshake first | none |
| Reliability | ACKs and retransmission | none; lost data stays lost |
| Ordering | delivered in order | may arrive out of order |
| Overhead | 20–60 byte header, slower | 8-byte header, faster |
| Typical uses | web (HTTP), file transfer, email | DNS, live video and voice calls, online games |
- TCP's guarantees cost extra round trips, and waiting whenever a packet is lost.
- UDP suits traffic where speed matters more than perfection, or where the application adds only the reliability it needs, as QUIC (used by HTTP/3) does.
Example: Downloading a PDF uses TCP: one missing byte would corrupt the file, so it is worth waiting for a retransmission. A video call uses UDP: if a fragment of audio is lost, playing it half a second late would be worse than simply skipping it.