COBOL Manual for TNS and TNS/R Programs
Process Initiation, Communication, and
Management
HP COBOL Manual for TNS and TNS/R Programs—522555-006
31-7
$RECEIVE
As with any other read operation, a process waiting to receive a message on
$RECEIVE waits until a message is delivered, the process is stopped, or a timeout
occurs on the read operation.
Before a process can receive a message, some process must have sent a message to
it.
To send a message, a process must have the name of the process that is to receive
the message (see Process Names). The sending process opens a file having the same
name as the receiving process (using an OPEN statement). Then the sending process
can write to its file and cause the operating environment to deliver the message to the
receiving process. The receiving process then can read the message on its
$RECEIVE.
If a process tries to open a nonexistent process, both the operating environment and
the HP COBOL run-time routines issue error messages. If no declarative intercepts the
error, the process terminates.
The sender of a message specifies whether a reply is expected or not. An HP COBOL
process uses a WRITE statement to send a message to which no reply is expected
and a READ WITH PROMPT statement to send a message that requests a reply. The
READ WITH PROMPT statement reads the reply to the message that is transmitted as
the prompt. The READ WITH PROMPT statement lets you write a requester in
HP COBOL, because it enables you to send a request to a server and await a reply
from that server. For more information on READ WITH PROMPT, see PROMPT
phrase.
Topics:
•
$RECEIVE as Separate Input and Output Files
•
$RECEIVE as Input-Output File
$RECEIVE as Separate Input and Output Files
The most common way to use $RECEIVE is to open it in INPUT mode for one file, and
in OUTPUT or EXTEND mode for one or more other files.
Figure 31-2. $RECEIVE as Separate Input and Output Files
Requester Server
Reply Message through RESPONSE-OUT
Task Message through TASKS-IN
Reply Message through ERROR-MSG
VST710.vsd