TCP vs UDP
Once a message is chopped into packets, there are two different ways to send them across the network. TCP is the careful courier: it shakes hands first, delivers everything in order, and re-sends anything that gets lost. UDP is fire-and-forget: it just throws the packets out fast and never looks back. Neither is 'better' — they're built for different jobs.
TCP — the careful courier
TCP acts like a courier who refuses to lose anything. Before sending, it does a quick three-step hello with the other side (the handshake) to confirm both are listening. Then it numbers every packet, watches for an acknowledgement that each one arrived, and if a packet goes missing it sends that one again. It also hands the data to the receiver in the right order, even if packets showed up jumbled. All that checking costs a little time, but you get a guarantee: what you sent is exactly what arrives, complete and in order. That's why web pages, file downloads, emails, and chat messages use TCP — losing a chunk of a file or scrambling your message would be a disaster.
UDP — fire and forget
UDP skips all the ceremony. No handshake, no numbering to wait on, no checking that each packet arrived, no re-sending. It just blasts the packets out as fast as possible and moves on. If a packet gets lost or arrives late, oh well — UDP doesn't even notice. That sounds careless, but for some jobs it's exactly right. In a live video call or an online game, being ON TIME matters more than being perfect. If one tiny slice of video gets lost, you don't want everything to freeze while it's re-sent — by the time the replacement arrived, that moment is already gone. Better to drop it and keep moving. So UDP trades guarantees for speed.
How to tell which one a job needs
Ask one question: do I need every byte to arrive perfectly, or do I need it to arrive fast and fresh? If correctness wins — a file, a web page, a bank transfer, a typed message — use TCP. A late-but-perfect delivery is fine; a corrupted one is not. If freshness wins — a live call, a fast-paced game, live audio — use UDP. A slightly imperfect stream that stays in real time beats a perfect one that lags behind. Same packets underneath; the choice is whether you want the careful courier or the speedy one.
It's a tradeoff
| Option | 👍 Pro | 👎 Con |
|---|---|---|
| TCP (careful courier) | Guarantees every packet arrives, complete and in order — re-sends anything lost. Perfect for web pages, files, and messages where correctness matters. | The handshake, acknowledgements, and re-sending add delay; a single lost packet can hold up the rest while it's re-sent. |
| UDP (fire and forget) | No handshake or re-sends, so it's lightweight and fast — ideal for live video, voice, and games where being on time beats being perfect. | No guarantees: packets can be lost, duplicated, or arrive out of order, and UDP won't fix it — the program has to cope or just live with the gap. |
Questions you might have
▸Is TCP just better than UDP? Why would anyone use UDP?
Neither is better — they're for different jobs. TCP's guarantees cost time, and for a live call or game, time is the whole point: a frozen-but-perfect video is worse than a smooth one that drops a tiny piece. UDP wins exactly when being on-time matters more than being flawless.
▸What actually happens if a UDP packet gets lost?
Nothing automatic — UDP doesn't notice or re-send it. In a video call that just shows up as a brief glitch or a skipped instant, then it carries on. The program decides whether to ignore the gap or paper over it, but UDP itself never goes back for the missing piece.
▸What's the handshake, and does UDP have one?
The handshake is TCP's three-step hello (SYN, SYN-ACK, ACK) where both sides confirm they're listening before any real data moves — press play on this topic's animation to watch it. UDP has no handshake at all; it starts sending immediately, which is part of why it's faster.
▸Do TCP and UDP both still chop the message into packets?
Yes — both ride on the same packet system from the last topic. The difference isn't the packets; it's the care taken with them. TCP numbers, tracks, reorders, and re-sends them; UDP just sends and forgets. Same envelopes, very different delivery service.
Best read after: Packets & routing