HTML and CSS Reference
In-Depth Information
The WebSocket protocol describes, in detail, the exact steps a client and server take to es-
tablish a WebSocket connection, exchange messages, and ultimately close the WebSocket.
To make a node, or any web server, accept WebSocket connections, you need to implement
the WebSocket protocol. In this section you'll get an overview of how that protocol works.
The following listing is a set of HTTP headers that the browser will send to the server in
order to initiate a WebSocket connection.
Listing D.1. The WebSocket handshake
A typical server response is shown in the next listing.
Listing D.2. The server response
Once the handshake is complete, data exchange can begin. The messages in WebSockets
are sent in what are referred to as frames. FigureD.6 shows the structure of a frame. Frames
 
Search WWH ::




Custom Search