The following two Pascal programs illustrate the use of the
RPM intrinsics. The first program creates a new process (the second
program) on a remote node. It also creates a remote session for
the second program to run in. At the same time, it passes strings
containing a socket name and a node name to the remote process.
This information enables the second program to establish a connection
to the first.
In greater detail, the first program:
creates a call socket and names it;
reads the name of the node on which it is running;
initializes the opt parameter
with strings containing the socket's name and the name
of the node on which it is running;
creates a new process with the program name CREATURE
on a remote node, passing the strings to the new process;
waits for a connection request from the remote process
(and establishes the connection);
shuts down its call socket;
executes a loop in which it:
calls a procedure that receives a
message by executing two IPCRECV
loops. The first loop determines the incoming message length. The
second loop receives data until all the pieces of the message have
been received.
prints the message that was received;
receives a "last message" termination
request;
sends a "termination confirmation message"
in response to the termination request;
receives a result parameter
value of 64 ("REMOTE ABORTED CONNECTION") in response
to a receive request;
The execution of the second program is initiated by the first
program. The second program:
obtains the socket name and node name
passed by the creator;
uses these names to acquire a destination descriptor
for the socket;
creates a call socket for itself, sends a connection
request to the creator's socket, and establishes a connection
to the creator process;
executes a loop in which it:
reads a line of data from the data
file;
stores the length (number of bytes) of the data
in the first part of the message;
stores the data itself in the second part of the
message;
sends the message on the connection, including the
message length as the first two bytes of the message;
after all the data is transmitted
from the data file, sends a "last message" that
will be recognized by the receiving program as a termination request;
receives a "termination confirmation message"
and shuts down the connection by releasing its VC socket.