Using NS3000/iX Network Services (36920-90008)

156 Chapter 7
Remote Process Management
RPM Program 1
else
rlen := 0;
end; { procedure receive }
begin {creator}
{create call socket, then name it}
ipccreate ( 3, 4, , , calldesc, result); {call socket, TCP protocol}
check (result); {error procedure}
socketname := 'MYSOCKET';
ipcname (calldesc, socketname, 8, result);
check (result);
{place rpmstring with socket information in opt parameter}
prompt('What is the name of your local node? ');
readln(datastr);
len := strlen(datastr);
strmove(len,datastr,1,nodename,1);
fginitopt(opt, 2); {2 option entries}
addopt(opt,0,20000,8,socketname); {option entry 0, rpmstring option code}
addopt(opt,1,20000,len,nodename); {option entry 1, rpmstring option code}
{create remote process and remote session;
the program file CREATURE must exist in the logon group for VPRES.ACCNTG on the
remote node}
progname := 'CREATURE';
location := 'REMNODE';
login := 'VPRES.ACCNTG,PUB';
for i := 0 to 30 do flags [i] := false; {false=0, true=1
for each bit in array}
flags [31] := true; {set dependent flag}
rpmcreate (progname,8,location,7,login,14, , ,flags,opt,pd,result);
if result < > 0 then
begin
writeln('RPM ERROR # is ',result);
terminate;
end;
{wait for connection request from remote process}
ipcrecvcn (calldesc, vcdesc, , , result);
check (result);
ipcshutdown (calldesc);
{receive messages on connection and print them;
repeat until 'END' message received}
repeat
begin
receive (vcdesc, data, len, result);
check (result);
setstrlen(datastr, len);
strmove(len, data, 1, datastr, 1);
if datastr < > 'END' then writeln (datastr); {print data received}
end
until datastr= 'END';
writeln('END received');
data := 'Y'; {shutdown procedure}
ipcsend ( vcdesc, data, 1, , , result );
check (result);
receive ( vcdesc, data, len, result );
if result = 64 then ipcshutdown( vcdesc )
else check ( result );
end. {creator}