WebSocket is one of the most promising features that HTML5 has to offer. As covered in Chapter 2, WebSockets and Server-sent Events, the traditional request-response model incurred an overhead due to the HTTP headers. With WebSockets, once the initial handshake is done the client and server or peers can communicate directly without the use of headers. This reduces the network latency and gives a reduction in HTTP header traffic.
Chapter 2, WebSockets and Server-sent Events, also introduced Server-sent Events and provides a comparison between SSE and WebSockets.
Server-sent Events define an API where the server communicates and pushes events to the clients as they occur. It is a one-directional communication from the server to the client and has more benefits as compared to traditional polling and long polling techniques.
This chapter covers advanced concepts of WebSockets and Server-sent Events and covers the following sections...