HTML and CSS Reference
Figure 4-2. Web application layer diagram
Figure 4-2 includes HTTP for two reasons. One, it illustrates that HTTP exists as an
application layer protocol on top of TCP that can be used directly in web applications.
AJAX applications use HTTP as their primary or only protocol for all network interaction.
Second, Figure 4-2 shows that applications using WebSocket do not need to completely
ignore HTTP. Static resources are almost always loaded over HTTP. For instance, the
even when you choose to use WebSocket for communication. As such, in your application
protocols stack, you might use both HTTP and WebSocket over TLS and TCP.
WebSocket really shines when used as a transport layer for standard application-level
protocols. In doing so, you can reap the amazing benefits of a standard protocol along
with the power of WebSocket. Let's take a look at some of these benefits by examining the
widely used standard chat protocol, XMPP.
XMPP: A Streaming Mile of XML
Chances are high that you have read and written your fair share of XML (eXtensible
Markup Language). XML is part of a long heritage of markup languages based on angle
brackets stretching back several decades through SGML, HTML, and their ancestors. The
World Wide Web Consortium (W3C) publishes its syntax and many web technologies
use it. In fact, prior to HTML5, XHTML was the ordained successor to HTML4. The X in XML
stands for eXtensible, and XMPP makes use of the extensibility it affords. Extending XMPP
means using XML's extension mechanism to create namespaces, which are called XEPs
XML is a format for documents; XMPP is a protocol. So, how does XMPP use
document syntax for real-time communication? One way to accomplish this is to send
each message in a discrete document. However, this method would be unnecessarily
verbose and wasteful. Another way is to treat the conversation as one long document that
grows as time passes and messages are transmitted, which is how XMPP approaches the