Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 49
Passing Messages Between Processes:
No Reply Data
The following example reads a message from $RECEIVE:
CALL READ^FILE(RECV^FCB,
READ^BUFFER,
BYTES^READ);
If you choose not to explicitly reply to the message, then on the next READ^FILE
call issued by the server against $RECEIVE, SIO will notice that the preceding
READ^FILE was never matched with a WRITE^FILE. SIO will then send a reply
for the preceding READ^FILE.
Sending and Receiving Messages in One-Way
Communication: An Example
The example shown in Figure 15-6 shows a client and a server process engaging in
one-way communication to pass messages from one terminal user to another. Note
that the code for each process is identical, but the input and output files assigned to
each process at run time are different.
Each process initializes an FCB for the input file and an FCB for the output file and
opens both files with read/write access. Each process then enters a loop that reads a
message from the input file and then copies the same message to the output file.
The differences between the two processes are in the input and output files that are set
up at run time. For the server process, the RUN command names the server $SERV
and designates $RECEIVE as its input file. The output file defaults to the home
terminal as specified in the Startup message.
The requester process takes its home terminal as its input file and $SERV as its output
file.
The combined action of the requester and server processes is as follows:
1. The requester process prompts the terminal user for a message using a call to the
READ^FILE procedure.
2. The requester sends the same message to the server process by issuing a
W
RITE^FILE procedure call to $SERV. The requester then waits for the write to
finish.
3. The server process reads the message from its $RECEIVE file using the
R
EAD^FILE procedure. The requester remains suspended while the server
processes the request.
4. The server writes the received message to its home terminal by issuing a
WRITE^FILE procedure call.
5. The requester is reactivated when the server issues the next READ^FILE call.
Both processes terminate when the user at the sending terminal types “EXIT.”
Figure 15-6 shows the code for the pTAL version of the program, and Figure 15-7
shows the code for the TAL version.