The CO4 protocol takes advantage of the KAPI messaging services, and like KAPI uses an Agent Name Server (ANS) supported by an HTTP server to manage clients as agents. It thus requires KAPI to be installed. The CO4 package is made of two libraries, libCo4, the main one, and libKapi2, built on top of KAPI which adds some functions like mailboxes, so KAPI (libkapi.a) is still required. The package also contains 6 cgi-scripts, to deal with ANS requests:
A CO4 repository is a process running as a demon, exchanging KQML messages with other CO4 repositories, for example a demand of registration. A TCP port ("KQML port" in the remainder) is dedicated to this repository to communicate with its peers and the corresponding URL (host and port) is recorded by the ANS at the creation of the repository. This allows KQML messages to only deal with repository nicknames, without knowing their physical address.
Before each emission of a message, the ANS is requested for the URL of the target, as shown in . Several repositories can run on the same host, by choosing different KQML ports.
Figure . Communication scheme of the Co4 protocol. Two repositories B1 (located
on host1) and B2 (located on host2) communicate through an ANS (located on
ANS-host). B1 requests the URL of B2, so the ANS retrieves in the files of B2
its URL, tcp://host2:1000, and returns it to B1. On its side, B2 asks to save
data, so the ANS returns to it the result of the corresponding script execution
The ANS also deals with repository management requests, because it stores repository data, by the way of the cgi-scripts presented above. The ANS used by CO4 has been enriched to store all data relating to the repositories. So, let a HTTP server be on a host, with a scripts directory located in $HTTP_BIN_ROOT, and a documents directory located in $HTTP_DOC_ROOT. CO4 installation will copy the 6 Co4_ scripts in $HTTP_BIN_ROOT, and make a directory named CO4 in $HTTP_DOC_ROOT. Each registered repository will have an account in this directory CO4, to store:
Figure . The various directories and files that can be found in the ANS HTTP
CO4 provides a HTML interface to visualise the repository and to manipulate the CO4 primitives. This repository behaves as a server for some HTTP clients (web browsers). It uses another TCP port (server port in the remainder), different from the KQML port, to communicate with its clients, via a routing script, named Co4_routingScript and located in $HTTP_BIN_ROOT. This script receives a URL, extracts the server port from it, sends and receives data from the repository through that port, and finally, returns HTML code to the browser to be displayed, as shown in .
Several servers can run on a same host, by choosing different server and KQML ports.
Figure 4. A click on the HTML interface of B1 displayed by a browser causes a
call to the routing script, that retrieves the server port of B1
(tct://lotse:6000) from the URL, then sends data to B1, gets some HTML code
from it, and finally returns this code to the browser to be displayed. The KQML
port (tcp:5551) is always active in order to let B1 receive KQML messages send
by other repositories.