Zeus Server Distributed Content API

Overview
Zeus Server provides a high-performance CGI replacement which allows dynamic documents to be provided to its clients. The dynamic document API utilises a TCP/IP socket interface to allow the document generation code to be implemented on a separate machine to facilitate load-balancing, and also makes no restrictions on the implementation language.

The dynamic document generation code, called sockd here in, runs as an external daemon to the server and listens for the request from the server to generate a page. The server then passes information, similar to the environment setup for a CGI process, to the sockd server, which can then use this information to determine the data for the page to generate. This information is then routed back through the server down to the client. This offers significant performance increases over frequently forking a large CGI script.

Usage
The sockd runs as a daemon process, listening on a defined port number. In order to access the sockd from the webserver, an alias is created by the webmaster to map requests for certain urls onto sockd servers. The aliases generally have the form /server/socket/name where name is a service name setup in the webserver configuration to map onto a sockd server. Following this alias, there can optionally be PATH_INFO information and URL arguments.

Details
A sockd server is a standard UNIX daemon which listens on a port number for requests from the server, and responds as detailed below. Multiple simultaneous requests may be outstanding at any one time.

Input

ENVIRONMENT\r\n
DATA\r\n

Where:
ENVIRONMENT = (LINE\r\n)+
LINE = environment variable line (e.g. HTTP_USER_AGENT=ZeusBrowser)
DATA = data supplied to POST, or arguments supplied to GET

ENVIRONMENT contains all of the fields that are set in the environment of a normal CGI program.

Output

As normal CGI

Example Sockd Server
An example sockd server is available here. This is a simple page-counter implemented in Perl which demonstrates how to interact with the API.