TMF Application Programmer's Guide (G06.24+)

Designing Single-Threaded Processes
HP NonStop TMF Application Programmer’s Guide—522419-004
2-12
Opening $RECEIVE
Opening $RECEIVE
To open the $RECEIVE pseudofile, a single-threaded server uses an FILE_OPEN_ call
of the following form (illustrated in TAL).
filename
specifies the character string $RECEIVE.
filenumber
is the name of a variable into which the FILE_OPEN_ procedure returns a unique
value identifying the $RECEIVE pseudofile. You use filenumber in
READUPDATE and REPLY calls to accept incoming messages and reply to the
associated requesters, respectively.
nowait-depth
is the name of a variable containing the FILE_OPEN_ nowait-depth parameter.
For a single-threaded server, this parameter is either a 0 or a 1. Zero (0) indicates
that I/O operations are to be waited, while 1 specifies that I/O operations are to be
completed by an AWAITIO call (nowait).
1
is the receive-depth value, specifying that the server can have only one incoming
message in $RECEIVE at any given time. Note that if multiple incoming messages
arrive within the same time period, none will be lost. The receive-depth of 1 means
that, having read one message through a READUPDATE call, the server cannot
read the next message until it has issued a reply to the first message.
A process can open $RECEIVE only once; attempts to open multiple instances of
$RECEIVE will fail with a condition code of CCL and the error number 12 (file in use).
You close $RECEIVE by specifying filenumber in a CLOSE procedure call. Note
that if the server has a transaction in progress (a work request message in $RECEIVE
for which a reply has not yet been sent) when you close $RECEIVE, TMF
automatically aborts the transaction associated with the work request.
Matching Each READUPDATE With a REPLY
Servers accept incoming work requests by way of the message system and the
$RECEIVE file.
If the incoming message is a work request from a requester, the server must issue a
corresponding reply message when it has finished doing the assigned tasks. If the
server fails to reply, the only possible outcome for the associated transaction is
CALL FILE_OPEN_ ( filename:8 , filenumber , , ,
nowait-depth , 1 );