Computer Networking
WebSockets, SSE & Polling
Getting data from the server without asking: polling, server-sent events and WebSockets compared on directionality, infrastructure, reconnection and scale.
The question this module answers · The server has news. How does it tell a browser that only ever asks?
WebSockets
▶ interactive
A WebSocket starts as an HTTP request that asks to switch protocols, gets `101 Switching Protocols`, and from then on the same TCP connection carries framed messages in both directions for as long as both sides want — which makes every proxy, load balancer and idle timer between them part of the design.
Polling vs Long Polling vs SSE vs WebSockets
▶ interactive
Four ways to get data from a server that has news to a client that only asks: repeated requests, requests the server holds open, a one-way HTTP stream with built-in reconnection, and a bidirectional socket — each trades infrastructure simplicity against latency and directionality.