Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

16.6 The Document Server Protocol

So far, we've ignored the issue of how the client and the server communicate, the single most important issue in the net library. The code we write sends data back and forth over a communication channel. Before we can write this code, we need to define just what information we are going to send back and forth. The rules for what information is exchanged and when are called the protocol.

We use a stateless, one-shot protocol to implement the server. Since the protocol is one-shot, a new connection is established not just for each client, but for each request. Once a request is satisfied the connection is closed. Next time a client wants to use the server it has to start over. After each request is satisfied the server forgets all about the client-it is stateless. Note that "stateless" means that the server does not retain state information about the client, not that it keeps no state itself.

Our protocol follows this sequence of events:

  1. A connection is established between client and server. Both client and server communicate via Rogue Wave virtual streams. The virtual streams take care automatically of data format differences between machines, and also allow us to use the Rogue Wave persistence machinery to effortlessly transmit complicated interrelated sets of objects.

  2. The client transmits a request. The request begins with an RWCString indicating the operation requested (either "find" or "insert").

  3. The server transmits a reply back to the client.

  4. The connection is closed.

16.6.1 Find Protocol

A find request consists of a single RWCString giving the key that we are looking for. The server replies by sending the web back to the client. If no document with the key is found in the server, a default document is sent back to the client.

16.6.2 Insert Protocol

A client inserts a new element into the collection by following the request code with an RWCString giving the key, and following that with the web to be stored. The server replies with the RWCString "ok" to indicate that it received and executed the request. If an element with the indicated key already exists, it is replaced.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.