loading...

Discussion on: Explain WebSockets like I'm five

Collapse
buzzingbuzzer profile image
Akash

You have a agreement with your best friend that she'll help with your math homework when you're stuck.

When you have a question, you call her, wait for her to answer, then ask your question, and listen while she replies. Then she hangs up and you carry on with your homework.

Most evenings, you call her a few times over the course of an hour or so. Sometimes she's too busy to answer, so you hang up, twiddle your thumbs and try in a few minutes.

But some evenings, homework is too hard, and you're practically calling her every five minutes. Although she doesn't mind helping you, neither of you are happy about the constant process of dialling her, waiting for her to answer, and hanging up, only to do the same thing a few minutes later.

Finally you settle upon a sane solution. You call her, and keep the line open. There's silence while you're working on your own, but when you have a question, you just have to start speaking and she can already hear you. When your homework is over, you can hang up for the evening.

Your friend is the server, you're the browser app, the call is a network connection and keeping the line open after calling is a websocket connection.

Collapse
daveblythe profile image
Dave Blythe (he/him)

Well done (including the responders)!
As a junior dev, there's a ton of buzzwords out there that seem to live right at the very edge of understanding. Like... I've always had a somewhat vague concept of what a web socket would need to do to be called a web socket (and suddenly I'm talking like I'm five!)... but would not be able to accurately describe web sockets using complete sentences (and I'm finding that hand gestures and facial expressions aren't much help, either).

This gives me a solid 'metaphor' framed in something nice and concrete and warm that I'm better able to retain. Being a very visual person, I can admit to having struggles early on trying to 'visualize' some of the abstractions I needed to work with, simply because I couldn't 'see' the data structure (electrical/mechanical background) involved.

Our Lead/Architect (and a great mentor) used to go above and beyond with me (I carried a small whiteboard to his desk, sneaker-net style)... taking time to draw out the tougher bits.

I'm LOVIN' this "Five Year old" series!