Glossary

WebSocket

WebSocket is a full-duplex communication protocol between a browser and server over TCP. Unlike HTTP — where the client always initiates a request — WebSocket lets the server push data to the client at any moment. Ideal for chats, online games, and live dashboards.

How the connection is established

It starts as a regular HTTP request with an Upgrade: websocket header. The server confirms the upgrade — and the TCP connection remains open. Both sides can send messages at any time, with no overhead of a new HTTP request.

Alternatives

Server-side libraries

Node.js: Socket.io, ws. PHP: Ratchet, Swoole, ReactPHP. Go: gorilla/websocket. Python: websockets, FastAPI WebSocket. In production, a dedicated WebSocket server is often run alongside the main HTTP application.