Networking interview question · Most asked

What's the difference between TCP and UDP, and when would you choose UDP?

Create a free account to save this page, take notes and track your progress. Sign in

Summary

TCP provides a reliable, ordered byte stream with connection setup, retransmission, flow and congestion control. UDP sends independent datagrams with no handshake or delivery guarantees. Choose UDP for small request/response exchanges (DNS), real-time media where late data is useless, or when a protocol implements its own reliability (QUIC).

Longer Answer

UDP's 8-byte header and lack of state make it cheap, but firewalls and NAT must track UDP flows by timeouts, and many networks block it. QUIC (under HTTP/3) runs over UDP to get independent streams, faster connection setup and connection migration, while implementing reliability and encryption itself.

Key Points

  • TCP: reliable, ordered, connection-oriented.
  • UDP: datagrams, no guarantees, no handshake.
  • UDP for DNS, media, games, QUIC.
  • UDP is often blocked or rate-limited on corporate networks.

Deep dive: Networking Tutorial: UDP

Explanation

What interviewers look for

Trade-offs, with real examples, including QUIC.

More most-asked Networking questions

← All Networking questions

Was this page helpful?