Tip 32Chatting with Web Sockets

Web developers have been pursuing real-time interaction with users for many years, but most of the implementations have involved using JavaScript to periodically hit the remote server to check for changes. HTTP is a stateless protocol, so a web browser makes a connection to a server, gets a response, and disconnects. Doing any kind of real-time work over a stateless protocol can be quite rough. The HTML5 specification introduced web sockets, which let the browser make a stateful connection to a remote server.[78] We can use web sockets to build all kinds of great applications. One of the best ways to get a feel for how they work is to write a chat client—which, coincidentally, AwesomeCo wants for its support site. ...

Get HTML5 and CSS3, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.