Networking · Updated 2026-06-05

TCP vs UDP

TCP is the default for anything that must arrive intact and in order; the kernel handles retransmission, ordering, flow control, and congestion control for you. UDP is the right base when you would rather handle loss yourself than pay for head-of-line blocking — real-time media, DNS, and modern protocols like QUIC all build on it.

TCP
Reliable, ordered, connection-oriented byte stream.
Since
1981
By
IETF (RFC 793, now RFC 9293)
License
Open standard
www.rfc-editor.org/rfc/rfc9293 ↗
UDP
Connectionless datagrams with no delivery guarantees.
Since
1980
By
IETF (RFC 768)
License
Open standard
www.rfc-editor.org/rfc/rfc768 ↗

These are not competitors so much as two different contracts with the network. TCP promises a reliable ordered stream and hides the messy parts. UDP promises almost nothing and hands you the raw datagram. The choice is really a question of who should own reliability: the kernel, or your application.

Quick takes

If you're…

  • You are moving files, loading web pages, or running an API TCP Loss and reordering would corrupt the payload; TCP handles both transparently.
  • You are carrying live voice or video UDP A late packet is useless; retransmitting it only adds jitter. Drop and move on.
  • You send small request/response pairs like DNS lookups UDP One datagram each way avoids a three-way handshake per query.
  • You need ordered delivery across many logical streams TCP TCP guarantees order — though all streams share one connection and one HoL queue.
  • You want to build your own reliability and congestion control UDP QUIC, WireGuard, and game netcode all do exactly this on top of UDP.
  • You are behind restrictive middleboxes or firewalls TCP TCP on 443 traverses almost everything; UDP is more often blocked or rate-limited.
Decision wizard

A few questions, a verdict.

Q1

Does every byte need to arrive, in order?

Q2

How latency-sensitive is the workload?

Q3

Who should own reliability and congestion control?

At a glance

The scorecard.

Dimension
TCP
UDP
Edge
Handshake + shared state
No setup, fire-and-forget
depends
ACKs + retransmit
Best-effort only
TCP
Strict order
Any order
TCP
One loss stalls the stream
Losses are independent
UDP
Window + CUBIC/BBR
BYO pacing
TCP
20+ bytes, handshake
8 bytes, no setup
UDP
Typical uses ecosystem
Web, mail, DB, files
DNS, media, QUIC
tie
In depth

Dimension by dimension.

core

Connection model

depends
TCP

Connection-oriented. A three-way handshake (SYN, SYN-ACK, ACK) establishes state on both ends before any data flows, and a four-way teardown closes it.

UDP

Connectionless. Each datagram is independent; there is no handshake and no shared state to set up or tear down.

core

Reliability

edge: TCP
TCP

Guaranteed delivery via sequence numbers, acknowledgements, and retransmission of lost segments.

UDP

None. Lost, duplicated, or reordered datagrams are the application’s problem to detect and handle.

core

Ordering

edge: TCP
TCP

Bytes are delivered to the application in the exact order sent.

UDP

No ordering guarantee; datagrams can arrive in any order.

core

Head-of-line blocking

edge: UDP
TCP

A single lost segment stalls everything behind it until it is retransmitted — painful when multiplexing many streams over one connection (HTTP/2).

UDP

No HoL blocking; a lost datagram never holds up the next one.

features

Flow & congestion control

edge: TCP
TCP

Built in: a receive window for flow control plus congestion control (CUBIC, BBR) that backs off under loss.

UDP

None by default. Applications that flood UDP without their own pacing can cause congestion collapse.

ops

Header & overhead

edge: UDP
TCP

20-byte minimum header, plus connection state and handshake round-trips before data.

UDP

8-byte header, no handshake — the lightest standard transport.

ecosystem

Typical uses

tie
TCP

HTTP/1.1 and HTTP/2, TLS, SSH, SMTP, database wire protocols, file transfer.

UDP

DNS, DHCP, NTP, VoIP/RTP, video streaming, gaming, QUIC (and thus HTTP/3).

When to pick neither

A different shape of problem.

  • You want TCP-grade reliability with per-stream independence — built on UDP
  • SCTP
    Message-oriented transport with multi-streaming; used in telecom signalling
  • WireGuard / custom UDP
    You are building a VPN or game netcode and want full control of the wire
Situational picks

For specific cases.

A web API or anything over HTTP

TCP

HTTP/1.1 and HTTP/2 ride TCP; reliability and ordering are exactly what request/response needs.

Live video conferencing or multiplayer games

UDP

A dropped frame should be skipped, not resent. UDP plus app-level recovery is the standard shape.

A new high-performance protocol

UDP

Build on UDP like QUIC did: you get reliability without TCP’s per-connection head-of-line blocking.

DNS resolution

UDP

One datagram each way; fall back to TCP only for responses too large for a single packet.

Sources

Primary material.

Found this useful?