Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 63
The Order-Query Server ($SER3)
!------------------------------------------------------------
! Main procedure calls INIT to perform initialization and
! then goes into a loop in which it reads the $RECEIVE file.
! It calls the appropriate procedure depending on whether the
! message read was a system message, a user message, or
! whether the read operation generated an error.
!------------------------------------------------------------
PROC SERVER MAIN;
BEGIN
INT COUNT^READ;
INT ERROR;
! Initialize files and opener table:
CALL INIT;
! Loop forever:
WHILE 1 DO
BEGIN
! Read a message from $RECEIVE and check for an error:
CALL READUPDATEX(RECV^NUM,SBUFFER,BUFSIZE,COUNT^READ);
CALL FILE_GETINFO_(RECV^NUM,ERROR);
! Get the process handle of the requesting process:
CALL FILE_GETRECEIVEINFO_(RECEIVE^INFO);
! Select a procedure depending on the results of the
! read operation:
CASE ERROR OF
BEGIN
! For a user message, call the PROCESS^USER^REQUEST
! procedure:
0 -> CALL PROCESS^USER^REQUEST;
! For a system message, call the
! PROCESS^SYSTEM^MESSAGE procedure:
6 -> CALL PROCESS^SYSTEM^MESSAGE;
! For any other error return, call the FILE^ERRORS
! procedure:
OTHERWISE -> CALL FILE^ERRORS(RECV^NUM);
END;
! Reply to the message: