Guardian Programmer's Guide

Table Of Contents
Communicating With Processes
Guardian Programmer’s Guide 421922-014
6 - 15
Receiving Messages From Other Processes: One-
Way Communication
Receiving Messages From Other Processes:
One-Way Communication
Now look at how one-way communication works. When receiving messages in one-
way communication, all the server has to do is read the message and process it. No
reply data is necessary in the reply.
To receive a message from another process, the server process must open the
$RECEIVE file and read from it. The following paragraphs explain how to do this if
your program will not send a reply to the sending process.
Opening $RECEIVE for One-Way Communication
As for two-way communication, the receiving process reads messages from the
$RECEIVE file. For one-way communication, however, it is not necessary to set the
receive-depth parameter to a nonzero value because the receiving process does
not return any reply data. You therefore open the $RECEIVE file using the
FILE_OPEN_ procedure as shown below:
FILE^NAME ':=' "$RECEIVE";
LENGTH := 8;
FILE_OPEN_(FILE^NAME:LENGTH,
RECV^NUM);
IF <> THEN ...
Reading From $RECEIVE for One-Way Communication
Use the READ[X] procedure to read the first message from $RECEIVE. In addition to
reading the message, the READ[X] procedure also keeps the requester and server
processes synchronized by terminating the WRITE[X] or WRITEREAD[X] procedure
call that the requester used to send the message.
CALL READX(RECV^NUM,
SBUFFER,
RCOUNT);
IF <> THEN ...
If you want to send an error response to the requester process without sending any
other data, use the READUPDATE[X] and REPLY[X] procedures as used for two-way
communication. You also need to open $RECEIVE with a receive depth of at least 1.
Because the requester sent the message using the WRITE[X] procedure, WRITE[X]
waits for the reply to finish but discards any data sent in the reply. By calling the
FILE_GETINFO_ procedure after the WRITE[X] procedure, the requester can obtain
the error code sent in the reply.
Sending and Receiving One-Way Messages: An Example
The example shown in Figure 6-5 shows one-way communication between a requester
process and a server process. The requester process writes messages to the server