TCP vs UDP: differences, examples, and when to use each protocol
Published on 2026-10-20 by frfrand
TCP delivers a reliable, ordered stream; UDP sends datagrams without those guarantees. Understand the difference with examples of web, games, DNS, and QUIC.

Short answer: TCP establishes a connection and delivers a complete, ordered byte stream, retransmitting what is lost; UDP sends individual datagrams, without connection or delivery guarantees. TCP is used on the web with HTTP/1.1 and HTTP/2, in SSH, and in databases; UDP, in DNS, games, voice, and in QUIC, the basis of HTTP/3.
TCP and UDP are transport protocols used to send data between applications over a network. TCP offers a reliable and ordered byte stream; UDP sends datagrams without guaranteeing by itself that they arrive, that they arrive only once, or in the same order.
This does not mean TCP is always better. Each protocol solves different needs. To understand them, imagine you need to send information between two computers.
With TCP, the transport confirms receipt, recovers losses, and presents the bytes in order. With UDP, you send individual messages and the application decides what to do if one is lost.
There is an important detail: TCP does not preserve message boundaries. If you send two blocks, the receiver could read them together or in several parts. The application must define how to separate them. UDP does preserve the boundary of each datagram, although it does not promise its delivery.
How TCP works?
Before exchanging data, the endpoints establish a connection. TCP uses sequence numbers, acknowledgments, retransmissions, and flow control and congestion control mechanisms.
Thanks to that, an application receives an ordered stream even if some segments are lost along the way. Recovery has a cost: when data is missing, the application cannot simply treat it as received.
TCP is common in SSH, many database connections, and HTTP/1.1 or HTTP/2 over TLS.
TCP alone does not encrypt the content. When confidentiality is needed, security layers such as TLS are used. That is why a reliable transport should not be confused with a secure connection.
How does UDP work?
UDP allows sending datagrams without TCP's connection establishment phase. Its header is smaller and leaves it up to the application to decide what to do in case of losses, delays, or duplicates.
This does not mean UDP is always faster or less secure. An application can build authentication, encryption, congestion control, and loss recovery on top of UDP.
An important example is QUIC, used by HTTP/3. QUIC runs over UDP and adds connection, security, and reliable delivery mechanisms when appropriate.
That is why it is not correct to say that "all websites use TCP": HTTP/3 uses a different transport, even though the browser continues to display a normal web page.
TCP vs UDP: a quick comparison
| Question | TCP | UDP |
|---|---|---|
| How does it deliver data? | Continuous stream of bytes | Individual datagrams |
| Does it guarantee delivery and order? | Provides reliable and ordered delivery mechanisms while the connection operates | Does not provide those guarantees by itself |
| Does it need to establish a connection? | Yes | No, although an application over UDP can do so |
| Does it include native encryption? | No | No |
| Where does it appear? | SSH, several databases, HTTP/1.1 and HTTP/2 | DNS queries, certain real-time applications, QUIC |
The practical question is not which one is "more modern," but what guarantee your application needs. If you transfer a document, it usually matters to receive it complete. If you send dozens of positions per second in a video game, it may be preferable to receive the most recent update rather than wait for an older one. Even so, each application can add its own logic over either transport.
What changes when configuring the firewall?
TCP and UDP use port numbers, but they are distinct protocols. Allowing 443/tcp is not the same as allowing 443/udp. A website serving HTTP/3 may require UDP on the corresponding port; another that only uses HTTP/2 may work with TCP.
Before opening ports, check the protocols your server actually uses. Having both open "just in case" is not a security policy. And even if a port is allowed in the firewall, that does not prove a service is listening behind it.
You can expand the explanation in what is a firewall in Linux, where network rules are described with examples.
Example: multiplayer video games
In an action game, receiving the player's position 200 milliseconds ago can be less useful than receiving their current position. Some applications send frequent updates and tolerate occasional losses, so UDP can be a good basis.
This does not mean that all traffic in a game should be UDP. Movements, chat, purchases, and important events may require different strategies.
Example: DNS queries
DNS frequently uses UDP for traditional queries, but it can also use TCP and other transports depending on the operation and protocol used.
The phrase "DNS only uses UDP" leads to incomplete network configurations. An administrator must check what transport their service actually needs.
Three common mistakes
"UDP is always faster." Final performance depends on the application, the network, and the guarantees you need.
«TCP avoids all errors». TCP recovers losses while the connection is working, but it does not replace data validation or failure handling.
«UDP is only for streaming». It is used in DNS, games, and modern protocols such as QUIC.
How does it relate to ArduMaker?
In ArduMaker, when deploying an application on a VPS, it is also necessary to know whether the service uses TCP, UDP, or both. Port redirects that carry Internet traffic to your VPS are created by specifying the protocol, tcp or udp, so a service that uses both needs one redirect for each. Web traffic from a published domain, on the other hand, enters through the host's nginx, which serves HTTPS over TCP (HTTP/1.1 and HTTP/2).
In summary: choose TCP when you need a reliable and ordered flow provided by the transport. Consider UDP when you work with datagrams and want to manage times, losses, or guarantees in another way, as QUIC does.
Frequently asked questions
Does HTTP use TCP or UDP? HTTP/1.1 and HTTP/2 use TCP; HTTP/3 uses QUIC, which works over UDP.
Does DNS use TCP or UDP? Common queries go over UDP to port 53, but DNS also uses TCP, for example for large responses or zone transfers.
Is UDP insecure? Not by itself. Neither TCP nor UDP encrypts; security is added by layers such as TLS or the one incorporated by QUIC.
Official sources: TCP, RFC 9293 · UDP, RFC 768 · QUIC, RFC 9000 · HTTP/3, RFC 9114.
