The Definitive Guide to HTML5 WebSocket is Now Available

A little while ago, we announced that our book, The Definitive Guide to HTML5 WebSocket, was on the horizon. Frank Salim, Peter Moskovits, and I are super excited to share the news that we finished writing the book and it’s NOW AVAILABLE. Yay!

The Definitive Guide to HTML5 WebSocket

This book provides an introduction to WebSocket, then describes the WebSocket API and Protocol and provides hands-on examples. We deep dive into three use cases for WebSocket, all using higher-level standard protocols (text and binary) over WebSocket. We walk through building a grown-up version of a chat application using XMPP/WS, a rock-paper-scissors game using pub-sub and STOMP/WS, and desktop sharing using RFB/WS (VNC). Finally, we examine security and deployment considerations. The book comes with the source code you need to get the demos up and running, as well as an easy-to-use VM with screencasts that show you what you’ll build.

Watch two of the authors, Vanessa and Peter, give a 90 second overview of the book:

Here’s an excerpt from Chapter 1, “Introduction to HTML5 WebSocket” from The Definitive Guide to HTML5 WebSocket (Apress, 2013):

WebSocket is about Performance

WebSocket makes real-time communication much more efficient.

You can always use polling (and sometimes even streaming) over HTTP to receive notifications over HTTP. However, WebSocket saves bandwidth, CPU power, and latency.

WebSocket is an innovation in performance.

WebSocket is about Simplicity

WebSocket makes communication between a client and server over the Web much simpler.

Those who have already gone through the headache of establishing real-time communication in pre-WebSocket architectures know that techniques for real-time notification over HTTP are overly complicated. Maintaining session state across stateless requests adds complexity. Cross-origin AJAX is convoluted, processing ordered requests with AJAX requires special consideration, and communicating with AJAX is complicated. Every attempt to stretch HTTP into use cases for which it was not designed increases software complexity.

WebSocket enables you to dramatically simplify connection-oriented communication in real-time applications.

WebSocket is about Standards

WebSocket is an underlying network protocol that enables you to build other standard protocols on top of it.

Many web applications are essentially monolithic. Most AJAX applications typically consist of tightly coupled client and server components. Because WebSocket naturally supports the concept of higher-level application protocols, you can more flexibly evolve clients and servers independently of one another. Supporting these higher-level protocols enables modularity and encourages the development of reusable components. For example, you can use the same XMPP over WebSocket client to sign onto different chat servers because all XMPP servers understand the same standard protocol.

WebSocket is an innovation in interoperable web applications.

WebSocket is about HTML5

WebSocket is part of an effort to provide advanced capabilities to HTML5 applications in order to compete with other platforms.

Every operating system needs networking capabilities. The ability for applications to open sockets and communicate with other hosts is a core feature provided by every major platform. HTML5 is, in many ways, a trend toward making web browsers fully capable application platforms that are analogous to operating systems. Low-level networking APIs like sockets would not mesh with the origin security model or API design style of the Web. WebSocket provides TCP-style networking for HTML5 applications without wrecking browser security and it has a modern JavaScript API.

WebSocket is a key component of the HTML5 platform and an incredibly powerful tool for developers.

You Need WebSocket!

Simply put, you need WebSocket to build world-class web applications. WebSocket addresses the major deficiencies that make HTTP unsuitable for real-time communication. The asynchronous, bidirectional communication patterns enabled by WebSocket are a return to the general flexibility afforded by transport layer protocols on the Internet.

Think about all the great ways you can use WebSocket and build true real-time functionality into your applications, like chat, collaborative document editing, massively multiplayer online (MMO) games, stock trading applications … the list goes on. We’ll take a look at specific applications later in this book.

Published by Apress and available on Amazon, this is the first printed book (also available as an ebook, for the Kindle, as a Nook book, and other formats) fully dedicated to the WebSocket technology.

After reading this book, we hope you’ll be as excited and inspired to use WebSocket as we are.

Thanks to our colleagues Steve Atkinson and Frank Greco for being our detailed and excellent reviewers!