TL;DR
TCP is a connection-oriented, reliable byte-stream protocol; UDP is connectionless and best-effort. Choose TCP when correctness matters, UDP when latency and real-time behavior matter.
Comparison
| Aspect | TCP | UDP |
|---|---|---|
| Connection | Three-way handshake | None |
| Reliability | ACKs, retransmission, dedup | Not guaranteed |
| Ordering | Guaranteed | Not guaranteed |
| Flow/congestion control | Yes | No |
| Header | 20–60 bytes | 8 bytes |
| Model | Byte stream | Datagram |
Typical Uses
- TCP: HTTP/HTTPS, file transfer, email, databases.
- UDP: DNS, VoIP, video conferencing, online games, live streaming.
- Middle ground: QUIC (HTTP/3) runs over UDP while adding reliability and low latency.
Sources
- RFC 793 (TCP), RFC 768 (UDP)
- Wikipedia: Transmission Control Protocol / User Datagram Protocol
- IETF QUIC (RFC 9000)