TCP vs UDP — What's the Difference?
TCP is a connection-oriented protocol that guarantees ordered, reliable delivery of data; UDP is connectionless and sends packets without guaranteeing they arrive, arrive in order, or arrive at all.
Published October 3, 2026
TCP is connection-oriented and guarantees ordered, reliable delivery; UDP is connectionless and sends packets without guarantees but with less delay. Use TCP for web, email and files, UDP for live video, voice and games.
The concept
TCP performs a handshake, numbers every segment, retransmits losses and controls congestion. That reliability adds latency.
UDP just sends datagrams. Packets may arrive out of order, duplicated or not at all, so the application decides what to do. QUIC (HTTP/3) builds reliability on top of UDP.
TCP three-way handshake
Practical examples
TCP in Node
import net from 'net'
net.createServer(s => s.pipe(s)).listen(4000)UDP in Node
import dgram from 'dgram'
const s = dgram.createSocket('udp4')
s.send('ping', 5000, 'localhost')Which uses what
TCP: HTTP/1-2, SSH, SMTP, FTP
UDP: DNS, VoIP, video streaming, online games, QUICCommon mistakes
- Assuming UDP packets arrive in order.
- Using UDP for data that must not be lost without adding acknowledgements.
- Forgetting firewalls treat TCP and UDP ports separately.
Key takeaways
- TCP = reliable and ordered.
- UDP = fast and lightweight.
- Choose based on loss tolerance.
FAQ
Is UDP unreliable?
It gives no guarantees itself; applications can add them.
Which does DNS use?
Mostly UDP, with TCP for large responses.