NetIPC 3000/XL Programmer's Reference Manual (5958-8600)

Table Of Contents
218 AppendixD
Migration From PTOP to NetIPC and RPM
Example: Client-Server Application
label 1; {for error exit }
const maxnodelength = 51; {all lengths in bytes}
maxproglength = 24;
namelength = 20;
infolength = 60;
ccg = 0; {condition codes }
ccl = 1;
cce = 2;
type shortint = -32768..32767;
msgtype = packed array[1..30] of char;
var location: packed array [1..maxnodelength] of char;
progname: packed array [1..maxproglength] of char;
name: packed array [1..namelength ] of char;
info: packed array [1..infolength ] of char;
dsnum: shortint;
length: shortint;
function POPEN:
shortint; intrinsic; {PTOP master intrinsics}
procedure PWRITE; intrinsic;
function PREAD: shortint; intrinsic;
procedure PCLOSE; intrinsic;
function PCHECK: shortint; intrinsic;
procedure ERROR( msg: msgtype; errnum: shortint );
{----------------------------------------------------------------}
{ ERROR prints out an error message and associated PTOP error }
{ number, and then goes to the error exit to terminate the }
{ program. The PTOP slave will be terminated automatically. }
{----------------------------------------------------------------}
begin
writeln( 'Client: ', msg, 'PTOP error = ', errnum:3 );
goto 1;
end;
begin
prompt('Client: Enter the remote node name: ');
readln( location );
{-------------------------------------------------------------}
{ Create PSERVER slave on remote node (location). This }
{ requires a previous REMOTE HELLO for the remote node. }
{-------------------------------------------------------------}
progname := 'PSERVER ';
dsnum := POPEN( location, progname );
if ccode <> cce then
ERROR( 'POPEN on server failed', PCHECK(0) );
{------------------------------------------------------------}
{ Each pass of this loop gets a name, PWRITEs it to PSERVER, }
{ PREADs the info, and prints the info. If PSERVER cannot }
{ find the name, it will REJECT the PREAD. }
{------------------------------------------------------------}
repeat
prompt('Client: Enter name (or EOT to exit):');