Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 46
Passing Messages and Reply Text
Between Processes
communication, however, is no different than for any other use of nowait I/O. Refer to
Handling Interprocess Messages earlier in this section.
Before sending and receiving messages, all processes involved must have initialized
file FCBs for each file accessed by SIO procedures and must also have initialized the
common FCB. Refer to Initializing SIO Files Using TAL or pTAL DEFINEs, earlier in
this section. Specifically, the requester process must initialize at least an FCB for the
server process file, and the server process file must initialize at least an FCB for the
$RECEIVE file.
Sending a Message to Another Process: Reply Data
Expected
To send a message to another process and receive reply data, the requester issues a
READ^FILE procedure call. This call uses the same buffer to send a message and
receive the reply.
The following example sends 40 bytes from the I/O buffer to the server process
(designated as the process’s OUT file) and waits for a reply. The reply returns in the
same buffer, and the count of bytes is returned in the third parameter:
CALL READ^FILE(OUTFILE,BUFFER,BYTES^READ,40,40);
Receiving and Replying to Messages
The server process receives the message from the requester process by issuing a
READ^FILE procedure call against its $RECEIVE file. If waited I/O is used, the server
process waits on this call for requests to come in from a requester:
CALL READ^FILE(RECEIVE^FILEFCB,
BUFFER,
BYTES^READ);
When the READ^FILE call finishes, the server processes the received message before
replying to the requester. The reply is done by issuing a WRITE^FILE procedure call
against the $RECEIVE file:
CALL WRITE^FILE(RECEIVE^FILEFCB,
BUFFER,
WCOUNT,
ERROR);
By writing a message to $RECEIVE, the server process completes the READ^FILE
call issued by the requester. In addition to returning reply data and the length of the
reply, the WRITE^FILE procedure can also return an error indication to the server in
the reply-error-code parameter (the fourth parameter). You can use this
parameter to pass back to the requester an application-dependent error code. The
error number is picked up by the corresponding READ^FILE procedure in the
requester process in the error return.