what is websocket

in #websocket6 years ago (edited)

WebSocket is a communications protocol for a persistent, bi-directional, full duplex TCP connection from a user’s web browser to a server and an advanced technology that allows real-time interactive communication between the client browser and a server.


![image]()

It uses a completely different protocol that allows bidirectional data flow, making it unique against HTTP. Web Sockets on the other hand don’t need you to send a request in order to respond. They allow bidirectional data flow so you just have to listen for any data.

image
One of the obstructions to building web applications that handle rapidly changing content (think status updates and chat messages) is HTTP’s request/response model. In the race for micro-optimizations of such behavior sites eventually hit a wall in which the browser must continually poll the server for updates. In other words, the browser always initiates the request, be it GET, POST, or some other method.
Web Sockets are currently one of the ‘next big web technologies’ adopted by many developers. Great for real-time interactions, even including online games.

image

They are so useful you could be amazed you haven’t heard of it before, but did you know that libraries like Firebase are already using Web Sockets.


With WebSockets, data sent from the server triggers a browser event. For example, rather than checking every two seconds for a new chat message, the browser can use an event-driven approach that triggers when a WebSocket connection delivers new data from the server.

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.033
BTC 61726.60
ETH 3041.60
USDT 1.00
SBD 3.86