Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 52
Communicating With Multiple Processes
Communicating With Multiple Processes
A server process can respond to messages from more than one requester process
using either the one-way or the two-way communication model. Normally, however,
SIO permits only one process pair to have the server process open at a time. To allow
multiple openers, you need to handle the Open and Close messages in your
application rather than let SIO handle them. This way, you can permit as many
openers as you wish. See Handling System Messages, later in this section, for details.
Because your server program needs to handle Open and Close messages itself, you
also need to inform SIO that the server has been opened. Otherwise, SIO will assume
that the server has not been opened and will reject messages received on $RECEIVE
by returning error 60. A procedure call such as the following prevents SIO from
rejecting messages:
CALL SET^FILE(RECV^FCB,SET^RCVOPENCNT,1);
When multiple openers are permitted, user messages are queued on $RECEIVE for
the server to read. The server simply reads the first message on $RECEIVE,
processes it, then reads the next message, and so on.
Note that servers that use SIO procedures cannot queue messages for multithreaded
processing like regular Guardian procedure calls can. This is because the OPEN^FILE
procedure always opens $RECEIVE with a receive depth of one; therefore, the server
process can work with only one message at a time. Refer to Section 6,
Communicating With Processes, for details on how to perform message queuing with
Guardian procedure calls.
Handling System Messages
SIO handles system messages automatically. However, you can use the SET^FILE
SET^SYSTEMMESSAGES or SET^SYSTEMMESSAGESMANY operation to select
messages to be returned to your program for processing. How your program should
handle system messages is described later in this subsection. First, this subsection
discusses the way SIO processes system messages.
SIO processes system messages to achieve the following:
Keep track of openers
Keep track of the BREAK key