COBOL Manual for TNS and TNS/R Programs

Environment Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
6-64
RECEIVE-CONTROL Paragraph
RECEIVE-CONTROL Paragraph
You can write server processes in HP COBOL. The system file process named
$RECEIVE is the communication mechanism between a requester process and a
server process or between the operating system and any process (as if the process
were a server). When a COBOL server resumes execution upon the completion of a
READ on $RECEIVE, it can require information about the source of the message that
was delivered.
To define the two tables used by $RECEIVE, include a RECEIVE-CONTROL
paragraph in the Environment Division of your server process. In the CRE, the
RECEIVE-CONTROL paragraph used for a run unit is the one for the program that first
opens $RECEIVE. In the non-CRE environment, the RECEIVE-CONTROL paragraph
used for a run unit is the one in the main program.
The $RECEIVE mechanism of a server written in HP COBOL uses the receive-control
table (sometimes called the Requester table) to record the status of the requesting
processes that have opened the server. It uses the reply table to keep copies of the
replies it has sent to each requesting process.
When the requester is running as a process pair and the requester sends a message
and the backup process takes over before the requester receives a reply, the server
can resend the reply automatically if a CHECKPOINT statement is executed after the
server reads the requester’s message and before the server writes a reply (or
generates one automatically with another READ). In this case, the server does not see
the duplicate message. The CHECKPOINT statement can be executed even if the
server is not running as a process pair.
In the simplest case, when a single requester and a single server are involved and
neither is running as a process pair, the default tables can accommodate the
$RECEIVE operations.
The ERROR clause provides a means of specifying that the server itself (and not its
run-time routines) takes responsibility for specifying any error number that the
$RECEIVE mechanism is to deliver to the requester. The MESSAGE SOURCE phrase
provides a means of identifying the sender of any message arriving through
$RECEIVE. The REPORT clause provides a means of specifying the classes of
messages arriving at $RECEIVE that are to be delivered to the server, rather than
handled automatically by the $RECEIVE mechanism.
National literals and national data items cannot be used in a RECEIVE-CONTROL
paragraph.
In the non-CRE environment, the RECEIVE-CONTROL paragraph for a run unit is the
one in the main program. In the CRE, the RECEIVE-CONTROL paragraph for a run
unit is the one in the first program to open $RECEIVE.