COBOL Manual for TNS/E Programs (H06.03+)
Process Initiation, Communication, and
Management
HP COBOL Manual for TNS/E Programs—520347-003
31-15
Summary of $RECEIVE Rules
This at-end condition is handled as an end of file for $RECEIVE. If a file status code
data item is defined, it is set to “10” (EOF). Control passes to the statement in the AT
END phrase or to a USE procedure if no AT END phrase is present. If the server is a
Pathway server, it must stop itself when it detects an at-end condition.
An attempt to read a file when it is at end of file causes a permanent error, setting the
file status code to “30.” Ordinarily, the program must close and reopen the file before
any further activity is possible on that file. For $RECEIVE, however, the run-time
routines simulate a close/open sequence, relieving the program of this responsibility;
however, such a READ after end of file should include a TIME LIMIT phrase, or the
READ could wait indefinitely. See READ for Sequential or Dynamic Access.
When a server process has just begun execution and no entries are yet in its receive-
control table, an at-end condition will never occur before the first OPEN message is
received.
Summary of $RECEIVE Rules
These rules apply to programs that use $RECEIVE:
•
Files assigned to $RECEIVE must be sequentially organized and not described
with alternate keys or LINAGE clauses.
•
A RECEIVE-CONTROL paragraph in the Input-Output Section of the Environment
Division is necessary to define two internal tables essential to the function of
$RECEIVE. (Although the RECEIVE-CONTROL paragraph is optional, the default
tables permit only the most limited use of $RECEIVE.)
•
The OPEN SYNCDEPTH value in the requester process that opens the server
process must not exceed the sync value in the RECEIVE-CONTROL paragraph of
the server process.
•
Only one reply WRITE to each READ on $RECEIVE is allowed. If you fail to reply
to a message before you read the next one, the HP COBOL run-time routines send
a default reply. In this situation, you cannot reply to that earlier message.
•
A program can use $RECEIVE whether or not the program runs as a process pair.
•
The contents of the record area associated with $RECEIVE are subject to
modification by the HP COBOL run-time routines. Even if a process has not
requested delivery of system messages in the RECEIVE-CONTROL paragraph,
the run-time routines handle system messages in the $RECEIVE record area.
These unrequested messages are not delivered to the process. If a process
modifies the record area and then performs a read operation on $RECEIVE, the
portion of the record area beyond the actual received message can include residue
of such system messages.
•
If you want to know the length of the record you read from $RECEIVE, identify
them with RECORD IS VARYING... DEPENDING, which enables you to determine
the length of the message that was sent to $RECEIVE by the requester.










