I get why this question keeps coming up. A WebSocket stays open, remembers who you are, and lets the server push data to you without you asking for it again and again. So why are we still firing off a hundred separate HTTP requests for a single page load when we could just open one persistent pipe and be done with it? Honestly, the question sounds smarter than most people give it credit for — and the answer is not “because HTTP is better.” It’s a lot more nuanced than that.
I kept hearing “use WebSockets for real-time stuff” without anyone explaining what actually happens on the wire. So I went and read the RFC, poked at a few servers, and figured I’d write down what I found — including the part that confused me the most: whether WebSocket is a protocol of its own or just some clever trick on top of HTTP.
So what is a WebSocket? A WebSocket is a persistent, full-duplex communication channel between a browser (or any client) and a server, opened over a single TCP connection [1]. Full-duplex means both sides can send messages whenever they want — not just in response to a request. That’s the part that breaks the usual mental model of the web.