COBOL Manual for TNS and TNS/R Programs

Process Initiation, Communication, and
Management
HP COBOL Manual for TNS and TNS/R Programs522555-006
31-6
Communicating With a Process
Communicating With a Process
On an HP system, all processes communicate directly with one another through the
message system. The basic mechanism for access to the message system is
$RECEIVE.
Topics:
$RECEIVE
Process Names
Example of Simple Interprocess Communication
RECEIVE-CONTROL Paragraph
At-End Condition
Summary of $RECEIVE Rules
Simple Server Example
$RECEIVE
$RECEIVE is like one end of a communications conduit. It is similar to a courier who
brings you a message and can be dismissed or sent back with a reply.
From the perspective of a process, $RECEIVE appears to be a sequential file. The
syntax for communicating with $RECEIVE in an HP COBOL program is, therefore,
based on the syntax for communicating with an ordinary HP COBOL sequential file.
To receive a message from another process (including the operating environment), a
process must read $RECEIVE.
To reply to a message, a process must write to $RECEIVE. The operating environment
delivers the reply to the originator of the message. The process does not need to
determine where the message came from to reply to it.
ELSE
* -- Received raw error from NEWPROCESS system procedure.
* -- Decompose it into left byte and right byte values.
DIVIDE SU-ERROR
BY 256
GIVING NEWPROCESS-ERR-LEFT
REMAINDER NEWPROCESS-ERR-RIGHT.
DISPLAY PROC-FAILED
" -- NEWPROCESS error # = ("
NEWPROCESS-ERR-LEFT
","
NEWPROCESS-ERR-RIGHT
")"
...
Example 31-1. CREATEPROCESS Routine (page 3 of 3)