Chapter 8. Websockets
This chapter covers
- Understanding the basic difference between HTTP and TCP traffic
- Using Websockets and JavaScript to communicate in real time over the web
- Installing Node.js and building a simple TCP server
The Websockets specification is one of the most interesting and paradigm-shifting APIs in the HTML5 stack. When implemented in a web platform, your applications can go from sending a request and waiting for a response to talking to a server or other clients in real time.
With Websockets, you can build, for instance, a web application on a tablet device that can play a game with thousands of players in real time. MMOG (massively multiplayer online games) are already popular, and the versions based on HTML5 are getting more common all the time. How about a website that lets you fire it up, go for a run, and race with someone on the other side of the planet? Integrate Websockets with Geolocation, and you’re literally on your way in every sense. Or consider the live streaming of a concert where you get to interact with people in the audience or even the band. This is perfectly possible and may perhaps be commonplace very soon.