UDP, TCP, WebSockets and WebTransport

Play this lesson

Two ways to send

TCP delivers every byte, in order. If a packet is lost, it is sent again, and everything after it waits.

UDP sends single messages. Its 1980 standard, RFC 768, says plainly that "delivery and duplicate protection are not guaranteed".

Why action games like UDP

Remy's server sends each player's position 20 times a second. If one update is lost, the next one is already on its way and is newer anyway.

Over TCP, the lost update is sent again and every newer one waits behind it. That wait is called head-of-line blocking.

Quick check

Why do many action games send positions over UDP?

  1. A lost update is replaced by the next one, so nothing should wait for a resend
  2. UDP never loses packets
  3. TCP cannot send numbers
Show the answer

A lost update is replaced by the next one, so nothing should wait for a resend

Old positions are worthless once a newer one arrives. UDP lets the newer update through without waiting.

In the browser

A web page cannot open plain UDP. For years, browser games used WebSockets: RFC 6455, from 2011, gives "two-way communication" between page and server, "layered over TCP".

That makes WebSockets reliable and ordered, with TCP's waiting included.

WebTransport

WebTransport runs over HTTP/3 and QUIC, which is built on UDP. It offers reliable streams and also unreliable datagrams.

MDN gives game state updates "where each message supersedes the last" as an example for datagrams, and marks WebTransport Baseline 2026: current versions of the major browsers support it.

Pick the channel

Remy's server sends chat messages and player positions. Over WebTransport, which fits?

  1. Chat on a reliable stream, positions as datagrams
  2. Both as datagrams
  3. Both on one reliable stream
Show the answer

Chat on a reliable stream, positions as datagrams

A chat line must arrive. A position can be lost, because a newer one follows within 50 ms.

Reliable where it matters

Even a UDP game needs some things to arrive: a purchase, a planted seed, a chat line. Games add their own acknowledgements and resends for just those messages, and let positions fly.

Quick check

A WebSocket can skip an old position update to deliver a newer one sooner.

Show the answer

False

WebSockets run over TCP, so every message arrives, in order. A newer update waits for an older one to be sent again.

How often to send

The transport is one choice. The next is how often the server works out the world and tells everyone about it.

Bolt says: Next: tick rate and snapshots.

Fact-checked 12 October 2026