Guardian Programmer's Guide

Table Of Contents
Communicating With Processes
Guardian Programmer’s Guide 421922-014
6 - 10
Receiving and Replying to Messages From
Other Processes
Receiving and Replying to Messages From
Other Processes
First look at how two-way communication works. This subsection is concerned with
processes that read a message, process the message, and then reply to the sender
before reading the next message. The file system keeps track of where to send
replies. The following paragraphs describe how to perform two-way communication.
Here, it is assumed that the server processes each message in turn. That is, the
server reads a message from the top of $RECEIVE, processes and replies to this
message, and then reads the next message.
It is possible to read several messages and then process them in any order. Doing so
involves putting each message on a list of messages that have been read but not
replied to and then removing the message from the queue when the message is
replied to. The subsection Handling Multiple Messages Concurrently, later in this
section, describes how to do this.
Opening $RECEIVE for Two-Way Communication
The receiving process reads messages from the $RECEIVE file. For two-way
communication, the process must set the receive-depth to a value greater than
zero.
The receive depth specifies how many messages can be read by the server process
before any message is replied to. For one-way communication, this value defaults to
zero because no reply is intended and therefore there is no need to queue messages
in this way. When processing and replying to one message at a time, however, the
maximum number of messages that can be read but not replied to is one. Hence the
server process is opened with a receive depth of 1.
You set the receive depth using a parameter of the FILE_OPEN_ procedure as shown
below:
FILE^NAME ':=' "$RECEIVE";
LENGTH := 8;
RECV^DEPTH := 1;
ERROR := FILE_OPEN_(FILE^NAME:LENGTH,
RECV^NUM,
!access!,
!exclusion!,
!nowait^depth!,
RECV^DEPTH);
IF ERROR <> 0 THEN ...
Note that although the receive-depth parameter is in the same position in the
procedure call as the sync-depth parameter for disk-file opens, the purpose of the
parameter is different.