WebSocket is a new protocol of HTML5. It realizes the full-duplex communication between the client and the server, so that data can be transmitted quickly in both directions. A connection between the client and the server can be established through a simple handshake, and the server can actively push information to the client according to business rules. The advantages are as follows:
- When the client and server are transmitting data, the request header information is relatively small, about 2 bytes.
- Both the client and server can actively send data to each other.
- There is no need to create and destroy TCP requests multiple times, saving bandwidth and server resources.
It is strongly recommended that developers use WebSocket API to obtain data such as market conditions and trading depth.