Guardian Programmer's Guide

Table Of Contents
Communicating With Processes
Guardian Programmer’s Guide 421922-014
6 - 7
Writing Messages to Another Process
.
.
CALL AWAITIOX(PROC^NUM);
IF <> THEN ...
Writing a message for one-way communication with error return is no different from
that given in the above examples. The only difference is in the server process, which
must use READUPDATE[X] and REPLY[X].
Writing a Message: Reply Data Expected
Two-way communication expects reply data in reply to a written message. Here, you
use the WRITEREAD[X] procedure to send the message to the server and receive the
reply from the server in the same buffer.
Note that it is the action taken by the server process that determines whether one-way
or two-way communication is being used. For two-way communication, the recipient
process reads the message using a READUPDATE[X] procedure and then replies to
the message using the REPLY[X] procedure. WRITEREAD[X] returns when the
REPLY[X] procedure finishes, keeping the processes synchronized.
The following example sends a request for a database access to a server process.
The reply returns the information retrieved from the database. This example assumes
waited I/O.
STRUCT .RECORD;
BEGIN
INT FUNCTION^CODE;
INT ACCOUNT^NUMBER;
INT AMOUNT;
END;
RECORD.FUNCTION^CODE := ADD;
RECORD.AMOUNT := 250;
RECORD.ACCOUNT^NUMBER := 16735;
WCOUNT := $LEN(RECORD);
RCOUNT := $LEN(RECORD);
CALL WRITEREADX(PROC^NUM,
RECORD,
WCOUNT,
RCOUNT,
COUNT^READ);
IF <> THEN ...
Had the process been opened for nowait I/O, the WRITEREAD[X] procedure would
return immediately. The associated AWAITIO[X] call would finish on receipt of the
reply and synchronize the processes.
Note. It is possible for the server process to send reply data even though the requester used
the WRITE[X] procedure instead of WRITEREAD[X]. The file system simply discards the reply
without even sending an error code to the requester or the server.