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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.