In our last interview, we had a candidate who said TCP is better than UDP. When I asked why, he said something like, “Why would we even need an unreliable protocol? TCP is better because it confirms every packet.” It was clear he was missing some key concepts and didn’t really get why both exist. So I figured, hey, why not write something about it?
1. What is a Port?
Before we dive into protocols, let’s understand ports. Think of your computer as an apartment building. Each application is a resident, and ports are apartment numbers. They let data arrive at the correct destination within your system.
Think of an IP address like this:
Road 31, House 470, Mohakhali DOHS — that’s how you find the building.
Now inside that building, there are multiple flats. That’s where ports come in.
Flat 6A might be ExaNest, and Flat 7B? That’s Suman Bhai’s legendary Chipa.
In simple terms:
- The IP gets you to the right building.
- The port gets you to the right room inside it.
When your machine sends or receives data, it uses IP addresses to find the device, and ports to find the correct application or process. For example:
- Port 80 → HTTP (web browsing)
- Port 443 → HTTPS (secure web browsing)
- Port 53 → DNS
- Port 22 → SSH
So, every time data flows through the internet, it’s not just going to your device — it’s going to a very specific port on that device.
Without the correct port number, the computer wouldn’t know which application should handle the data.
2. TCP Ports vs UDP Ports
Here’s where things get interesting.
Both TCP and UDP use ports — but how they use them is where the difference lies.
Feature | TCP | UDP |
Connection | Connection-oriented | Connectionless |
Reliability | Reliable (ACKs, retransmit) | Unreliable (no ACKs) |
Speed | Slower (overhead) | Faster (no handshakes) |
Order | Guarantees order | No order guarantee |
Use Cases | Web, email, file transfer | Video, voice, gaming |
TCP (Transmission Control Protocol) is like sending certified mail — each package requires a signature (ACK), and if it doesn’t arrive, it’s re-sent. Reliable, yes — but it adds overhead.
UDP (User Datagram Protocol) is like dropping postcards in the mailbox. No confirmation, no guarantee — but it’s fast and lightweight.
What’s the Difference?
- TCP (Transmission Control Protocol)
Reliable, connection-based. Used where data must arrive complete and in order.
Think: Web browsing, file transfer, email. - UDP (User Datagram Protocol)
Faster, connectionless. Used where speed is more important than reliability.
Think: Video streaming, DNS lookups, online gaming.
This is the theoretical knowledge we have so far. So, why do we use UDP for video streaming and gaming even though there’s a risk of data loss?
Reason 1: Speed > Perfection
UDP is used because it’s fast and lightweight. It doesn’t wait for confirmation that the data was received. For streaming, this is a huge win.
- With TCP, every lost packet triggers retries and delays. That would cause buffering or lags in video.
- With UDP, it just keeps streaming. If a few packets (video frames) are dropped? You might see a tiny glitch or blur — but the stream keeps playing smoothly.
Reason 2: Tolerable Loss
Streaming services like YouTube, Netflix, Twitch, or Zoom can tolerate a little data loss.
- One lost video frame won’t ruin your experience.
- But waiting to re-download it (TCP style) could ruin the flow of your video or audio.
Reason 3: Lower Overhead
UDP has no handshake, no state tracking, no flow control — which means:
- Less data sent per packet
- Lower latency
- More efficient use of time, if not always bandwidth
This makes UDP perfect for:
- Live video
- Voice calls (VoIP)
- Online games
- Video conferencing
But yes, you’re right:
UDP can waste bandwidth — because:
- If data is lost, it’s not resent
- And sometimes that means retransmitting a chunk unnecessarily, or live content being glitchy
IMO, this is a trade-off:
📺 Smooth and fast > 📦 Perfect delivery
Final Thoughts
There’s no universal “better” when it comes to TCP vs UDP. Each has a purpose, a trade-off, and a place in the networking world.
Next time you’re in an interview — or designing a system — don’t just champion reliability. Understand the use case. Choose wisely.
And hey, if you’re ever building the next big video conferencing app, remember: sometimes it’s okay to drop a few packets to keep the conversation flowing. 😉