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

Table Of Contents
230 AppendixD
Migration From PTOP to NetIPC and RPM
Example: Client-Server Application
{----------------------------------------------------------------}
{ ERROR prints an error message and an associated NetIPC or RPM }
{ result code. It terminates the program by going to the error }
{ exit. Any NetIPC objects (sockets or virtual circuits) will }
{ be deleted upon termination. }
{----------------------------------------------------------------}
begin
writeln( 'Server: ', msg, 'Result = ', result:3 );
goto 1;
end; {ERROR}
procedure RECV( vcdesc: integer;
var buf: buftype;
length: integer;
var result: integer );
{----------------------------------------------------------------}
{ RECV receives a specified number of bytes from the virtual }
{ circuit (vc) connection. This compensates for the stream mode }
{ operation of NetIPC on the HP 3000, where an IPCRECV can return}
{ less than the requested number of bytes. The loop in RECV }
{ calls IPCRECV to receive the next chunk of data, until the }
{ requested amount of data has been received. Note that buf }
{ must be unpacked to allow it to be indexed in the IPCRECV call.}
{----------------------------------------------------------------}
var nextbufchar: integer;
recvlength: integer;
begin
result := 0;
nextbufchar := 1;
while (length <> 0) and (result = 0) do
begin
recvlength := length;
IPCRECV( vcdesc, buf[nextbufchar], recvlength, , , result );
nextbufchar := nextbufchar + recvlength;
length := length - recvlength;
end;
end; {RECV}
procedure FIND_NAME( var reqname: nametype;
var info: infotype;
var found: boolean );
{----------------------------------------------------------------}
{ FIND_NAME sequentially searches the data file for the requested}
{ name. It returns an indication of whether the name was found, }
{ and if it was found, the information field for the name. (In }
{ a real name server, a more efficient look up method would be }
{ used.) }
{----------------------------------------------------------------}
var filename: packed array[1..9] of char;
datafile: text;
name: nametype;