HTML and CSS Reference
In-Depth Information
addressing in the Web world is asymmetrical. Browsers can address resources on servers
via URLs, but there is no way for a server-side application to proactively send a resource to
a client. Clients can only make requests, and the server can only respond to outstanding
requests. In this asymmetrical world, protocols that require full-duplex communication
just don't work as well.
One way to work around that limitation is to have the client open HTTP requests just
in case the server has an update to share. The umbrella term for using HTTP requests to
reverse the flow of notifications is called “Comet.” As we discussed in the earlier chapters,
Comet is basically a set of techniques that stretch HTTP to the limit with polling, long
polling, and streaming. These techniques essentially simulate some of TCP's capabilities
in order to address the same server-to-client use cases. Because of the mismatch
between synchronous HTTP and these asynchronous applications, Comet tends to be
complicated, non-standard, and inefficient.
In server-to-server communication, each host can address the other. It is
possible for one server to simply make an HTTP request to the other when there is new
data available, which is the case with the PubSubHubbub protocol for server-to-server
feed update notification. PubSubHubbub is an open protocol that extends RSS and Atom,
and enables publish/subscribe communication between HTTP servers. While server-to-server
communication is possible with WebSocket, this topic focuses on client-server
communication in real-time web applications.
Note
Introducing the WebSocket Protocol
This short history of the Internet lesson brings us to today. Now, web applications
are quite powerful with significant client-side state and logic. Often, modern web
applications require bidirectional communication. Immediate notification of updates
is more the rule than the exception, and users increasingly expect responsive real-time
interactivity. Let's take a look at what WebSocket gives us.
WebSocket: Internet Capabilities for Web Applications
WebSocket preserves many of the things we like about HTTP for web applications (URLs,
HTTP security, easier message based data model, and built-in support for text) while
enabling other network architectures and communication patterns. Like TCP, WebSocket
is asynchronous and can be used as a transport layer for higher-level protocols.
WebSocket is a good base for messaging protocols, chat, server notifications, pipelined
and multiplexed protocols, custom protocols, compact binary protocols, and other
standard protocols for interoperating with Internet servers.
WebSocket provides TCP-style network capabilities to web applications. Addressing
is still unidirectional. Servers can send clients data asynchronously, but only when there
is an open WebSocket connection. WebSocket connections are always established from
 
 
Search WWH ::




Custom Search