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.
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.
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!