knowledge/technology/internet/WebSocket.md
2023-12-04 11:02:23 +01:00

1.2 KiB

obj wiki rfc website
concept https://en.wikipedia.org/wiki/WebSocket https://datatracker.ietf.org/doc/html/rfc6455 https://websockets.spec.whatwg.org

WebSocket

WebSockets provide a bidirectional communication channel over a single, long-lived connection. This enables real-time, low-latency data exchange between a client and a server.

WebSocket Protocol

1. WebSocket Handshake:

The WebSocket handshake is an HTTP-based protocol that establishes a connection between the client and server. Once established, the connection switches to the WebSocket protocol.

2. WebSocket Frames:

Messages in WebSockets are sent as frames. Frames can be text, binary, or control frames used for connection management.

Usage and Benefits

1. Real-Time Applications:

WebSockets are ideal for real-time applications like live chats, online gaming, financial trading, and collaborative tools.

2. Reduced Latency:

The persistent connection minimizes latency compared to traditional HTTP, making WebSockets suitable for applications requiring low-latency communication.

3. Efficient Data Transfer:

WebSockets use a compact binary frame format, reducing the overhead associated with text-based protocols.