HTML and CSS Reference
like the remote control to build more full-featured applications like chat clients and
servers. One of the great things about WebSocket is that you can layer other protocols on
top of WebSocket to extend your applications over the Web. Let's take a look at layering a
protocol over WebSocket.
Figure 4-1 shows a typical layering of Internet application layer protocols over TCP.
An application uses a protocol like XMPP or STOMP (Simple Text Oriented Messaging
Protocol, which we discuss in Chapter 5) to communicate between clients and servers.
XMPP and STOMP, in turn, are communicated over TCP. When using encrypted
Figure 4-1. Internet application layer diagram
communication, the application layer protocols are on top of TLS (or SSL), which in turn
is layered above TCP.
The WebSocket view of the world is much the same. Figure 4-2 shows a similar
diagram with WebSocket inserted as an additional layer between the application layer
protocols and TCP. XMPP and STOMP are layered on top of WebSocket, which is layered
on top of TCP. In the encrypted case, secure WebSocket communication using the
wss:// scheme is performed over a TLS connection. The WebSocket transport layer
is a relatively thin layer that enables web applications to establish full duplex network
connections. The WebSocket layer can be treated much the same as the TCP layer in
Figure 4-1 and used for all of the same protocols.