Home > Common Problem > What are the characteristics of websocket?

What are the characteristics of websocket?

hzc
Release: 2020-06-24 11:17:54
Original
3087 people have browsed it

What are the characteristics of websocket?

Features:

  • Less control overhead. When data is exchanged between the server and client after a connection is created, the packet headers used for protocol control are relatively small. Without extensions, for server-to-client content, the header size is only 2 to 10 bytes (related to the packet length); for client-to-server content, additional headers need to be added. 4-byte mask. Compared with HTTP requests that carry complete headers every time, this overhead is significantly reduced.

  • Stronger real-time performance. Since the protocol is full-duplex, the server can proactively send data to the client at any time. Compared with HTTP requests, which need to wait for the client to initiate a request before the server can respond, the delay is significantly less; even compared with similar long polling methods such as Comet, it can deliver data more times in a short period of time.

  • Stay connected. Unlike HTTP, Websocket needs to create a connection first, which makes it a stateful protocol, and some state information can be omitted during subsequent communications. HTTP requests may need to carry status information (such as identity authentication, etc.) in each request.

  • Better binary support. Websocket defines binary frames, which can handle binary content more easily than HTTP.

  • can support extensions. Websocket defines extensions, and users can extend the protocol and implement some customized sub-protocols. For example, some browsers support compression, etc.

  • Better compression effect. Compared with HTTP compression, Websocket, with appropriate extension support, can inherit the context of previous content and significantly improve the compression rate when transmitting similar data.

The above is the detailed content of What are the characteristics of websocket?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template