loading...

re: Explain WebSockets like I'm five VIEW POST

FULL DISCUSSION
 

Here's my try at it. I'm not a native english speaker, so I hope you'll forgive my mistakes. Also it's not meant to be technically accurate --

You want to know about Websockets ?
Ok, but first I have to explain Internet to you. Internet is like a bunch of tunnels, connecting all the computers and phones and stuff. In these tunnels, there's a lot of things, like pipes that we call UDP. And then there's this very neat conveyor belts we call TCP. They never lose anything, and everything arrives in the order it was sent, unlike the pipes. Also, they are 2-ways, that's very handy. Plenty of great uses : many many apps send and get packages with TCP.

There's a bunch of apps for example, like Firefox and Chrome, they all send similar packages with TCP : same label on the packages, no fancy post-stamps or whatever. This standard way to make the labels is called HTTP. There are other ways, but HTTP is widely used. (HTTP also has a variant with a padlock, it's called HTTPS :) ).

A small example that may ring a bell : among the uses of HTTP, there's this stuff called WWW. They are the websites you know. WWW it a way to organize the contents of the packages, like bubble-wrap, and labels on the goods.

Anyway, back to the HTTP labels.
Some people don't want every kind of package to come and go inside they computers or phones, because bad people could sent them packages filled with smelly cheese, or spiders or gross stuff. So they build Firewalls. For example, you can have a firewall that will burn to ashes any package on the conveyor belt, unless they have a regular HTTP label on them. That way, they feel safer.

The thing is, so many people have started to use these HTTP firewalls nowadays. And anyone sending a package wants to have this nice HTTP label on it, for fear of it being burned. But people really liked the conveyor belt too, because you could send anything through it.

So someone had an idea : What if we send a very very very long package on the conveyor belt. As long as the tunnel itself ! Long enough to go from one computer to another ! And with a nice looking HTTP label on it so the Firewalls won't burn it ! And when the computer who's receiving gets the first end of the package, it can unwrap just the end of it. And guess what's inside ? Another conveyor belt !!!! The computer who's sending still has the rear end of the package, because it's sooo very long. Both computers have kind of cheated the firewall, because now they have their very own conveyor belt and they can send anything they want inside something that looks like an HTTP package. And it's nice because it's also a 2-way conveyor belt. We call these very very long packages "Websockets".

Yes, it's a bit weird. And you're right to ask "Why don't we ask people to ease up on the Firewalls, and use the TCP conveyor belt instead ?". Maybe things could have gone a different way, but this is how it is today, so we have to deal with it. And there is another risk. Maybe people will start using better Firewalls, that can X-Ray the packages, and if they see a conveyor belt in it, they will look at the stuff that it carries, and burn it if they don't like it. But then people could also send very very long packages on the conveyor belt that's inside the HTTP package, and it could go on like that forever.

I, for one, hope it won't.

:)

code of conduct - report abuse