Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

WebSocket

Shulou Source: shulou.com Published: 2022-06-03 05:25:01 11月24日 Update

The reason for this is:

The "request-reply" mode of HTTP is "half-duplex". Although it can send and receive data in both directions, it can only act in one direction at a time, and the transmission efficiency is low.

More importantly, it is a "passive" communication mode, in which the server can only "passively" respond to the client's request and cannot actively send data to the client.

Not suitable for the development of "real-time communication" applications, low efficiency, difficult to achieve dynamic pages, so the emergence of WebSocket.

WebSocket

WebSocket is a lightweight network communication protocol based on TCP, which is on a par with HTTP in status.

WebSocket is a "full-duplex" communication protocol, which is equivalent to a "thin package" of TCP to run in a browser environment.

WebSocket uses HTTP-compatible URI to discover services, but defines new protocol names "ws" and "wss", and port numbers 80 and 443.

WebSocket uses HTTP protocol to realize the connection handshake. Sending GET requests requires "protocol upgrade". There is a very simple authentication mechanism in the handshake process to prevent misconnection.

WebSocket is a true "full-duplex" communication protocol, and like TCP, both the client and the server can send data to each other at any time. Once there is new data in the background, the server can immediately "push" to the client, without the need for client polling, the efficiency of "real-time communication" is also improved.

Tags: Communication customer client data service efficiency server duplex real-time mode initiative key action dynamic reason two-way slogan background status each other Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Microsoft Shulou Information Linux Shulou Tech Info