websockets
WebSockets are an alternative to HTTP communication in Web Applications.
WebSocket是Web应用程序中HTTP通信的替代方法。
They offer a long lived, bidirectional communication channel between client and server.
它们在客户端和服务器之间提供了长期的双向通信通道。
Once established, the channel is kept open, offering a very fast connection with low latency and overhead.
建立通道后,通道将保持打开状态,从而提供非常快速的连接,并具有较低的延迟和开销。
浏览器对WebSocket的支持 (Browser support for WebSockets)
WebSockets are supported by all modern browsers.
所有现代浏览器都支持WebSocket。
WebSockets与HTTP有何不同 (How WebSockets differ from HTTP)
HTTP is a very different protocol, and also a different way of communicate.
HTTP是一个非常不同的协议,也是一种不同的通信方式。
HTTP is a request/response protocol: the server returns some data when the client requests it.
HTTP是一个请求/响应协议:服务器在客户端请求时返回一些数据。
With WebSockets:
使用WebSockets:
the server can send a message to the client without the client explicitly requesting something
服务器可以向客户端发送消息,而无需客户端明确请求
the client and the server can talk to each other simultaneously
客户端和服务器可以同时对话
very little data overhead needs to be exchanged to send messages. This means a low latency communication.
发送消息所需的数据开销很少 。 这意味着低延迟的通信 。
WebSockets are great for real-time and long-lived communications.
WebSockets非常适合