Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 12
The Part-Query Server ($SER1)
On return from either the PROCESS^SYSTEM^MESSAGE or
PROCESS^USER^REQUEST procedure, the SERVER procedure replies to the
message. For a user message, the reply consists of a part record or an error
indication. For a system message, the reply consists of an error indication: 0 for a
successful operation or some positive number for an unsuccessful operation.
Procedures for Handling System Messages
Procedures for handling system messages include the
PROCESS^SYSTEM^MESSAGE, PROCESS^OPEN^MESSAGE,
PROCESS^CLOSE^MESSAGE, and PROCESS^OTHER^MESSAGE procedures.
The PROCESS^SYSTEM^MESSAGE procedure is called from the SERVER
procedure whenever the server reads a system message from the $RECEIVE file.
PROCESS^SYSTEM^MESSAGE calls one of the other procedures for handling
system messages, depending on whether the system message is an Open message, a
Close message, or some other system message.
If the system message is an Open message, then
PROCESS^SYSTEM^MESSAGE calls the PROCESS^OPEN^MESSAGE
procedure. This procedure tries to add an entry to the servers opener table. It
checks each 10-word entry in turn until it finds a blank entry (consisting of a -1 in
each word). The procedure then copies the process handle of the requester into
the blank entry and returns to the SERVER procedure with error number zero.
If the opener table is full, then the process returns error 12 to the SERVER
procedure.
If the system message is a Close message, then PROCESS^SYSTEM^MESSAGE
calls the PROCESS^CLOSE^MESSAGE procedure to check that the process
handle of the sending process exists in the opener table and to remove the entry.
If the process handle exists in the opener table, then error number zero is returned
to the SERVER process; otherwise, error 60 is returned.
If the system message is any system message other than Open or Close, then
PROCESS^SYSTEM^MESSAGE calls the PROCESS^OTHER^MESSAGE
procedure to make updates to the opener table if the message concerns a network
connection or CPU failure.
The PROCESS^USER^REQUEST Procedure
The PROCESS^USER^REQUEST procedure is called by the SERVER procedure
when a user message is read from the $RECEIVE file. Its function is to read a
specified record from the inventory file.
First, the PROCESS^USER^REQUEST procedure checks each entry in the opener
table to see whether the sender of the user message has this server open. If not, then
the procedure returns error number 60 to the SERVER procedure.
If the requesting procedure is in the server’s opener table, then the
PROCESS^USER^REQUEST procedure uses the part number provided in the user