TCP vs UDP: Differences, Examples and When to Use Each

TCP confirms every packet and keeps them in order; UDP sends without waiting. How each works, which apps use which, and what it means for proxies and HTTP/3.

ComparisonsPublished Oct 25, 20266 min read

On this page

TCP and UDP are the two main ways data travels across the internet. TCP opens a connection first, confirms that every packet arrives, resends the lost ones and delivers them in order, which suits web pages, APIs, email and file transfers. UDP sends packets without a connection or confirmation, so nothing waits for a lost packet, which suits calls, games, DNS lookups and HTTP/3. For proxy users, the difference decides which proxy you need: HTTP proxies carry only TCP, while SOCKS5 can carry UDP too.

TCP: the sender and receiver exchange SYN, SYN-ACK and ACK, then the sender sends packets 1 and 2; packet 2 is lost, packets 3 and 4 wait, the receiver asks for 2 and the sender sends it again. UDP: the sender sends packets 1 to 4 straight away; packet 2 is lost and simply gone
TCP sets up a connection and recovers lost data; UDP sends straight away and moves on.

TCP vs UDP at a glance

TCPUDP
ConnectionOpened with a three-way handshake before any dataNone: each packet is sent on its own
DeliveryEvery packet confirmed; lost ones are sent againNo confirmation; lost packets stay lost
OrderData arrives in the order it was sentPackets can arrive out of order
Flow and congestion controlSlows down when the receiver or the network is overloadedNone built in; the app decides
Header size20 bytes or more8 bytes
LatencyHigher: setup, waiting for confirmations and resendsLower and steadier
Typical usesWeb pages, APIs, email, file transfers, SSHCalls, games, DNS, live video, HTTP/3

How TCP works

Before sending data, TCP sets up a connection with a three-way handshake: the client sends SYN, the server answers SYN-ACK, and the client confirms with ACK. From then on:

  • Every segment is numbered and confirmed. The receiver acknowledges what it got. If a segment goes missing, the sender sends it again.
  • Data is delivered in order. If segment 2 is lost, segments 3 and 4 wait at the receiver until 2 arrives. This is called head-of-line blocking: one loss delays everything behind it.
  • The sender adapts its speed. TCP slows down when packets are lost, so it does not flood a busy network.

The result is a reliable stream: what goes in one end comes out the other complete and in order. That is exactly what a web page, a file or an API response needs, where a missing byte would break the result.

How UDP works

UDP adds very little on top of the internet itself: a source port, a destination port, a length and a checksum. There is no handshake, no confirmation and no ordering. Each packet (a datagram) is sent and forgotten.

That makes UDP the better fit for real-time traffic. In a call, a packet that arrives half a second late is useless, so it is better to drop it and play the next one than to pause the conversation waiting for a resend. Games, live video and voice all work this way, and DNS uses UDP because a lookup fits in one small packet and simply retries if no answer comes.

Apps that need some reliability on top of UDP build it themselves. The best-known example is QUIC, the transport under HTTP/3: it runs over UDP but adds its own encryption, confirmations and resends per stream, so one lost packet does not hold up every other request on the connection.

Which apps use TCP and which use UDP

TCP, where every byte must arrive in order: web pages and APIs over HTTP/1.1 and HTTP/2, email over SMTP and IMAP, downloads and uploads, remote shells over SSH. UDP, where late data is worse than lost data: voice and video calls over WebRTC and call apps, online games, DNS lookups on port 53, HTTP/3 over QUIC, some low-latency live streams
Complete data travels over TCP; live data over UDP.

Some protocols use both. DNS uses UDP for normal lookups and TCP for large responses. Call apps often try UDP first and fall back to TCP when UDP is blocked, at the cost of call quality. Browsers try HTTP/3 over UDP and fall back to HTTP/2 over TCP when UDP does not get through, so pages still load.

Is UDP faster than TCP?

For getting the first byte across and for steady real-time streams, yes: there is no handshake and no waiting for lost data. For moving a large file, not necessarily: TCP's flow control and resends are what make a big transfer finish correctly on a lossy network, and an app that sent a file over plain UDP would have to rebuild all of that. Choose by what the data needs, not by speed alone.

TCP, UDP and proxies

This is where the difference matters most if you use proxies:

Proxy typeTCPUDP
HTTP or HTTPS proxyYesNo
SOCKS5 proxyYesOnly if the provider supports UDP ASSOCIATE

An HTTP proxy works on top of TCP connections, so it cannot carry UDP at all. When a browser profile or app sends UDP through a proxy that does not carry it, that traffic either fails or goes out over your own connection, from your own IP. A SOCKS5 proxy can relay UDP, but the provider has to enable it and the app has to send its UDP through the proxy. The UDP proxy guide explains how that works, and SOCKS5 vs HTTP proxies compares the two protocols.

With NanoIP:

  • ISP proxies carry TCP over HTTP, HTTPS and SOCKS5, and UDP over SOCKS5, on every IP.
  • Residential and mobile proxies connect through the HTTPS gateway gateway.nanoip.net:1111, which carries TCP: web pages, APIs and data collection.

For web work, TCP is all you need. Choose a UDP-capable SOCKS5 proxy when the work includes calls, WebRTC, games or apps that rely on UDP, such as browser profiles used for account management that also make calls.

Frequently asked questions

Is UDP less secure than TCP?

Neither encrypts anything by itself. Security comes from the protocol on top: TLS over TCP for HTTPS, and QUIC's built-in encryption for HTTP/3 over UDP. UDP is easier to spoof because there is no handshake, which is why services that answer UDP carefully limit what they send back.

Do TCP and UDP use the same ports?

Both use port numbers from 0 to 65535, but they are separate: TCP port 53 and UDP port 53 are different endpoints. A firewall rule for one does not open the other.

Does HTTP/3 work through a proxy?

Not through an HTTP proxy, which only carries TCP. Browsers then use HTTP/2 over TCP for the same site, so pages load normally. To carry HTTP/3 itself, the proxy has to relay UDP, which in practice means SOCKS5 with UDP support.

Written by NanoIP Team · Proxy infrastructure and customer support team

Related articles

Comparisons

Mobile vs Residential Proxies: How to Choose

Mobile proxies exit through 4G/5G carriers, residential proxies through home broadband. How they differ in IPs, targeting and price, and when each fits.

6 min read

Need help with your setup?

Our support team can check your proxy configuration with you.