HTML and CSS Reference
THE REAL-TIME wEB is one of those golden eggs of the
Internet. Very cool when you come across it, but perhaps
quite daunting when it comes to building it. This chapter
will show you the choices of technology and how spec-
tacularly simple the client-side code is.
There are two options to add a real-time aspect to your
web application: Websockets and Server-Sent Events.
WebSockets let you create a connected stream to your
server (for server boffins out there: a TCP connection),
and allow two-way, real-time communication between the
server and the client. The typical hello world app is a chat
client, but the possibilities of use are endless. Sockets go
a long way toward replacing Comet-based code. Comet
uses a variety of—often quite hackish—techniques to
achieve real-time, streaming data from a server.
WebSockets simplify this process on the client side,
as we'll see later in this chapter.