TCP vs UDP: What's the difference?
TCP prioritizes reliable, ordered delivery, while UDP minimizes overhead and leaves reliability to the application when needed.
TCP
TCP establishes a connection, acknowledges data and retransmits missing segments to provide ordered delivery.
UDP
UDP sends independent datagrams without a connection handshake or guaranteed delivery, which reduces protocol overhead.
Key differences between TCP and UDP
| Decision factor | TCP | UDP |
|---|---|---|
| Connection model | Connection-oriented with a handshake and connection state. | Connectionless datagrams with no transport-layer session setup. |
| Reliability | Provides ordering, acknowledgements and retransmission. | Provides no delivery, ordering or retransmission guarantee by itself. |
| Overhead and latency | More transport overhead and state management. | Lower protocol overhead and useful for latency-sensitive or multicast-style patterns. |
Choose TCP if
Choose TCP when completeness, ordering and built-in retransmission matter more than minimum latency.
Choose UDP if
Choose UDP for real-time, broadcast or latency-sensitive traffic where the application can tolerate or handle loss.
Practical example
HTTPS normally uses TCP because a web session needs ordered, reliable delivery. Real-time voice and video often use UDP-based transports because waiting for retransmission can be worse than losing a small amount of media. Modern protocols such as QUIC run over UDP but implement their own reliability and congestion-control behavior above it.
Can you use TCP and UDP together?
Applications can use both protocols for different jobs. DNS commonly uses UDP for ordinary queries but can use TCP for larger responses and zone transfers. A voice platform may use TCP or TLS for signaling and UDP for the media stream. Always check the application protocol rather than assuming one transport for the whole product.
Common mistake to avoid
“UDP is faster” is an oversimplification. UDP removes transport guarantees, but the application may add its own reliability, encryption
Key takeaway
Neither protocol is universally faster or better: the application requirements determine whether reliability or low overhead matters most.
Frequently asked questions
Is TCP always more reliable than UDP?
TCP provides built-in reliable ordered delivery. UDP does not, although an application protocol can implement comparable guarantees itself.
Why does VoIP often use UDP?
Interactive audio values low latency. Retransmitting an old voice packet may be less useful than continuing with the next packet.
Can firewalls block one and allow the other?
Yes. TCP and UDP are separate IP protocols and firewall rules normally match them independently along with ports and addresses.