Maybe the most radical addition in HTML5 is the introduction of WebSockets as a persistent bidirectional communication between the client and server over the HTTP protocol, which is a stateless protocol.
As mentioned in Chapter 1, Introduction to Penetration Testing and Web Applications, WebSockets communication starts with the handshake between client and server. In the code shown in the following screenshot, taken from Damn Vulnerable Web Sockets (https://github.com/snoopysecurity/dvws), you can see a basic JavaScript implementation of WebSockets:
This code starts a WebSockets connection as soon as the HTML document is loaded. ...