WebSocket Basics
Real-time bidirectional comms.
Real-Time, Two-Way Communication
HTTP is request-response: the client asks, the server answers, the connection (logically) ends. For chat, live dashboards, and games you need a persistent, bidirectional channel. That is what WebSockets provide.
The Upgrade Handshake
A WebSocket connection starts as a normal HTTP request with special headers:
Upgrade: websocketConnection: Upgrade
The server responds 101 Switching Protocols, and the TCP socket is reused for full-duplex frames.