Card 10/ 10
Recap: Real-Time Protocols
Three ways to keep a connection open, each answering who may send and how it survives a drop.
Real-time protocols let data arrive when it exists rather than when the client asks.
- WebSocket upgrades an HTTP request with a 101 into a two-way channel of frames; the application reconnects after a drop.
- Server-sent events keep a GET response open and write text events into it; the browser reconnects and resumes with
Last-Event-ID. - WebRTC swaps an offer and answer through signalling, then sends encrypted media and data directly over UDP.
- ICE gathers host, STUN and TURN candidates and tests pairs; TURN relays when no direct path works.
- Idle timeouts close quiet connections; a heartbeat shorter than the shortest timeout keeps them open.
| Question | WebSocket | Server-sent events | WebRTC |
|---|---|---|---|
| How it starts | Upgrade and 101 | A long GET | Offer, answer and ICE |
| Who may send | Both | Server | Both peers |
| One message | A frame on TCP | Text lines | Encrypted UDP packets |
| After a drop | Application reconnects | Browser resumes | ICE restart |
← → move through sections and cards