What is a Websocket?
WebSocket is an advanced technology that makes it possible to open an interactive communication session between the user’s browser and a server. WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application.
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.
WebSockets address this design limitation of HTTP by providing a bidirectional, also known as full-duplex, communication channel. WebSocket URL connections use ws:// or wss:// schemes, the latter for connections over SSL/TLS.
Once a browser establishes a WebSocket connection to a server, either the server or the browser may initiate a data transfer across the connection. Previous to WebSockets, the browser had to waste CPU cycles or bandwidth to periodically poll the server for new data. 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.
No comments:
Post a Comment