DEV Community

Discussion on: Explain WebSockets like I'm five

Collapse
 
dwd profile image
Dave Cridland

One day, some clever people were looking at a river, and wondered how they could get some water back to their house. So they decided that they would use buckets.

Everyone thought that buckets where great. They could send robots with buckets down to the river anytime they wanted, and they'd get buckets full of water back. It didn't matter which robots, or which buckets, the water was always the same.

But one day, the clever people started to think about how difficult it was when they only wanted a glass of water every now and then, or when they wanted to have a bath. Because it was all just buckets, you either had loads of water, or else you had to have loads of buckets. It was only good if you actually wanted a bucket of water.

And so the clever people thought again. And now, instead of the robots carrying buckets down to the river, every now and then they'd carry a hose instead. Now a hose couldn't be reused by everyone, like the buckets, but it did mean you could just run it anytime you wanted a glass of water, or leave it running for ages if you wanted to fill a bath.

The river is a website. The house is a browser. The buckets are HTTP requests and responses. The water is data, of course. The hoses are websockets. The clever people in the house are the HyBi Working Group of the IETF, and I'm only saying they're clever because I was one of them. The robots are just robots. Because robots are cool.