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

Table Of Contents
Appendix D 231
Migration From PTOP to NetIPC and RPM
Example: Client-Server Application
begin
filename := 'DATAFILE ';
reset( datafile, filename );
found := false;
while not found and not eof(datafile) do
begin
readln( datafile, name, info );
if name = reqname then
found := true end;
end; {FIND_NAME}
begin
{-------------------------------------------------------------}
{ Retrieve the client's socket name and node name, passed as }
{ RPM strings. }
{-------------------------------------------------------------}
clientsocklength := socketnamelength;
RPMGETSTRING( clientsockname, clientsocklength, result );
if result <> 0 then
ERROR( 'Couldn't get socket name.', result );
clientnodelength := maxnodelength;
RPMGETSTRING( clientnode, clientnodelength, result );
if result <> 0 then
ERROR( 'Couldn't get local nodename.', result );
{-------------------------------------------------------------}
{ Create the server's socket, look up the client's socket, }
{ and set up a vc connection between the server and the client}
{ sockets. }
{-------------------------------------------------------------}
IPCCREATE( callsocket, tcpprotocol, , , socketdesc, result );
if result <> 0 then
ERROR( 'Couldn't create socket.', result );
IPCLOOKUP( clientsockname, clientsocklength, clientnode,
clientnodelength, destdesc, , , result );
if result <> 0 then
ERROR( 'Socket look up failed.', result );
IPCCONNECT( socketdesc, destdesc, , , vcdesc, result );
if result <> 0 then
ERROR( 'Socket connection failed', result );
{-------------------------------------------------------------}
{ Wait for the connection acknowledgement from the client. }
{-------------------------------------------------------------}
IPCRECV( vcdesc, , , , , result );
if result <> 0 then
ERROR( 'Socket connect receive failed.', result );
{-------------------------------------------------------------}
{ Once the connection is established, the socket and destina- }
{ tion descriptors are no longer needed. So delete them. }
{-------------------------------------------------------------}
IPCSHUTDOWN( socketdesc, , , result );
if result <> 0 then
ERROR( 'Couldn't shut down socket.', result );
IPCSHUTDOWN( destdesc, , , result );