Tuesday, May 03, 2005

Developer Guide - Server Push and Server Sockets

Developer Guide - Server Push and Server Sockets: "Server Push and Server Sockets

This section will describe how to send data to Mozilla from other sources.
Server Push

The term 'server push' generally means that a server pushes content to the browser client. In reality, a browser doesn't allow this directly. However, it may be emulated in a number of ways.

* The client polls the server at a certain interval, say every five minutes. This technique is typically used to update news information. The client does this by reloading a page every so often.
* The client uses the 'multipart/x-mixed-replace' content type when sending a response. The content type is expected to send a series of documents one after the other, where each one will replace the previous one. The server might delay between each part, which gives the illusion that the data is being updated after an interval. This technique requires a connection to stay open.
* In Mozilla 1.6 and later, server sockets may be used to listen for incoming connections. This technique works similarly to the way a server would listen to connections from a browser and doesn't require a connection to be kept open. However, server sockets may only be used from privileged code.

All three techniques may be used in Mozilla. The first technique is fairly simple and is described in a number of places that discuss web page development. Just use a meta-tag refresh or load data using the XMLHttpRequest object. The second technique listed above has been improved in Mozilla 1.7 to work with the XMLHttpRequest object, as well as with normal browser page loads. This additional feature is described below, as it is more unique to Mozilla. "

No comments: