TCP vs UDP: Differences, Uses and Examples
TCP and UDP are the two main ways to send data across the internet. They make different trade-offs between reliability and speed.
What is TCP?
TCP (Transmission Control Protocol) is reliable. Before sending data, the two computers set up a connection with a three-way handshake: SYN, SYN-ACK, ACK. TCP then numbers every piece of data, checks that it arrives, resends anything that is lost, and puts it back in the right order.
This care makes TCP a little slower, but you can trust the result.
What is UDP?
UDP (User Datagram Protocol) is simple and fast. It has no handshake, no resending and no ordering. It just sends packets and hopes they arrive. If a packet is lost, UDP does not notice or fix it.
TCP vs UDP: comparison
| TCP | UDP | |
|---|---|---|
| Connection | Connection-oriented (handshake first) | Connectionless |
| Reliability | Guaranteed delivery | No guarantee |
| Order | Data arrives in order | Order not guaranteed |
| Speed | Slower | Faster |
| Header size | 20 bytes or more | 8 bytes |
| Error recovery | Resends lost data | None |
| Examples | Web (HTTP/HTTPS), email, file transfer | Video calls, online games, DNS, live streaming |
Which one should you choose?
Choose TCP when every byte must be correct. A web page or a file with missing pieces is useless. Choose UDP when speed matters more than perfection. In a video call, a lost packet causes a tiny glitch, but waiting to resend it would cause a long delay, which is worse.
A simple way to remember
TCP is like a phone call: you connect first, and you hear if the other person is still there. UDP is like posting a letter without tracking: it is quick and cheap, but nobody tells you if it got lost.
Frequently asked questions
Is UDP always faster than TCP?
Usually yes, because it does less work. But if the network loses many packets, an application using UDP may need to handle the problem itself.
Which protocol does DNS use?
DNS mostly uses UDP for quick questions and answers. It switches to TCP for large responses.
What port does each protocol use?
Ports belong to the application, not the protocol. HTTP uses TCP port 80, HTTPS uses TCP port 443, and DNS uses port 53.