Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 3
Context-Free Servers
Note that COBOL85 programs do not support multithreaded servers. You cannot open
$RECEIVE with receive-depth value greater than 1 unless you use the ENTER verb to
call the file system FILE_OPEN_ procedure directly. (This is not recommended,
because it might adversely interfere with the COBOL85 RTL I/O mechanisms.) See
the COBOL85 Manual for details.
If you use a multithreaded server as a pathway serverclass, make sure that the value
of TCP SERVER LINKDEPTH is less than or equal to the receive-depth value. Note
that the LINKDEPTH value must be 1 in all other cases. For single-threaded servers, a
LINKDEPTH value greater than 1 disturbs the automatic load balancing feature in
Pathway.
Context-Free Servers
Generally, you should design your server processes to be context free. Such servers
have special advantages in application design. If the server retains no context, then
each requester can request service from a given server without concern for what the
server has previously done. Moreover, if multiple servers with identical function are
available, then a requester can ask for service from any such server.
Maintaining an Opener Table
You can provide security to a server process by using an opener table. This table is
maintained by the server and contains a list of all processes that have the server open.
This table provides two functions:
It allows you to know the number of processes that have the server open.
It allows you to check that each message received originated from a process that
has the server open
The Opener Table
An opener table typically consists of a sequence of 22-word entries. Each 22-word
entry either is null or contains, in the first 10 words, the process handle of a requester
that has this server open. If the process handle of a requester is present, the entry
also contains the file number that the requester is using for the open. (Using a file
number allows a requester to open a server more than once.) Associated with the
opener table is an integer variable indicating the current number of openers (entries in
the table).
The following declaration describes a typical opener table. Here, the maximum length
of the table is set by the literal MAX^OPENERS:
INT NUMBER^OF^OPENERS; !number of requesters that
! have the server open
!Opener table contains information about who has the server
!open:
STRUCT .OPENER^TABLE[1:MAX^OPENERS];