What are WebSockets? — Coding for Beginners



What are WebSockets? — Coding for Beginners

What are WebSockets? — Coding for Beginners

What are WebSockets? — Coding for Beginners

http://colorcode.io/course/tech-in-90-seconds/?video=websockets

Tech in 90 Seconds – WebSockets

Author: John K. Paul

WebSockets are another protocol, similar to http, but much more under the hood inside of browsers. You might have never seen a URL that starts with a WS in your browser’s location bar, but behind the scenes, many of your favorite applications, like Slack, Gmail, Twitter are using Web Sockets.

The typical HTTP request response cycle inside of a browser is something like 1. person clicks on link or types url in 2. http request is made to server 3. server responds to the browser with some data. This ask for something, get something kind of system works great for a huge variety of things, like reading the news or checking the weather, but if you want to get info more real time, like chatting, email or twitter, in this world, we’d have to be calling and saying ‘hey, anything else’, ‘hey, anything else?’ all of the time.

WebSockets purpose is to allow for a persistent’ connection with a backend server. It’s like a telephone call where either side never needs to hang up, and a new call doesn’t need to be made if new information comes in, seconds or minutes later. If the server has data for the browser, it just sends it, and doesn’t have to wait for another time that the browser asks ‘anything else?’

A developer using this technology can create a backend and frontend combination system that can very quickly and responsively react to new data as if it were a stream flowing into your browser and as such, WebSockets are a foundation of ‘Real time’ web applications.

Comments are closed.