“What’s the difference between TCP and UDP?” is one of the most common networking questions in software interviews, from campus placements to senior backend roles. The concepts are simple; what separates good answers is structure and the ability to handle follow-ups.
The 20-second answer
“TCP is connection-oriented: it sets up a connection with a handshake and guarantees that data arrives reliably and in order. UDP is connectionless: it just sends datagrams with no delivery or ordering guarantees, which makes it lighter and faster. We use TCP for web traffic, email and file transfer, and UDP for real-time things like video calls, gaming and DNS lookups.”
Say that first. Then go deeper only as far as the interviewer wants.
Side-by-side comparison
| Aspect | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented (three-way handshake) | Connectionless |
| Reliability | Acknowledgements and retransmission | No guarantee; packets can be lost |
| Ordering | Delivered in order | May arrive out of order |
| Flow & congestion control | Built in | None (left to the application) |
| Header size | 20–60 bytes | 8 bytes |
| Latency | Higher overhead | Lower overhead and latency |
| Typical uses | HTTP/1.1, HTTP/2, SMTP, SSH, FTP | DNS, VoIP, video streaming, online games, QUIC (HTTP/3) |
How TCP guarantees delivery
If the interviewer asks how, walk through these mechanisms:
- Three-way handshake (SYN, SYN-ACK, ACK) to establish the connection and agree on initial sequence numbers.
- Sequence numbers and acknowledgements, so the receiver can reorder segments and the sender knows what arrived.
- Retransmission of segments that aren’t acknowledged within a timeout.
- Flow control through the receive window, so a fast sender doesn’t overwhelm a slow receiver.
- Congestion control (slow start, congestion avoidance) to back off when the network is saturated.
Why real-time apps prefer UDP
In a video call, a packet that arrives half a second late is useless — the moment has passed. Retransmitting it, as TCP would, only adds delay and makes the stream stutter. UDP lets the application decide: drop the late frame, smooth over the gap and move on. That is why voice, video and multiplayer games run over UDP, adding only the lightweight reliability they need.
TCP vs UDP follow-up questions to expect
“So is UDP unreliable?”
UDP itself makes no guarantees, but applications can add exactly the reliability they need on top. QUIC — the transport underneath HTTP/3 — runs over UDP and implements its own reliable, encrypted streams without TCP’s head-of-line blocking.
“Why does DNS use UDP?”
Most DNS queries and responses fit in a single small packet, so setting up a TCP connection would take longer than the lookup itself. DNS falls back to TCP for large responses and zone transfers.
“Give an example where TCP is the wrong choice.”
Live audio. Waiting for a lost packet to be resent causes audible gaps; it is better to skip it and keep the conversation flowing.
Common mistakes
- Calling UDP “bad” or “insecure” — security is a separate layer (TLS, DTLS).
- Treating ordering and reliability as the same guarantee.
- Listing differences without examples. Always anchor to a real protocol or product.
Nail the one-line version, keep the table in your head and prepare for the QUIC and DNS follow-ups — that covers nearly every variation of this question.
Networking questions like this come up in almost every backend round. Practise with our bank of real interview questions, and read our guide on answering technical questions under pressure.
