Networking & IoT · Interview question

What does TCP provide that UDP doesn't?

A strong answer

TCP turns the unreliable, packet-by-packet IP layer into a reliable, ordered byte stream between two endpoints, and it does so through several mechanisms UDP lacks: a connection established via the three-way handshake; sequence numbers on every byte plus acknowledgments from the receiver, so lost segments are detected and retransmitted; reordering of out-of-order arrivals and de-duplication; flow control so a fast sender doesn't overrun a slow receiver's buffer; and congestion control so senders back off when the network is congested. UDP provides essentially none of this, it's a thin wrapper over IP that sends independent datagrams with no connection, no acknowledgments, no retransmission, and no ordering, so datagrams can be lost, reordered, or duplicated and the application is never told. The price TCP pays for its guarantees is per-connection state and buffers, handshake round-trips before any data flows, and head-of-line blocking; UDP's price is that any reliability or ordering you need, you build yourself. So the distinction isn't "TCP good, UDP bad", it's reliability-with-overhead vs best-effort-with-minimal-overhead.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

TCP vs UDP

The two transport protocols: TCP's connection, ordering, and retransmission (a reliable byte stream) vs UDP's connectionless best-effort datagrams, and which to pick on a constrained device.

More TCP vs UDP questions

Browse all 472 interview questions
What does TCP provide that UDP doesn't? | EmbeddedPrep.io