|
|
Microsoft Windows NT Pre-Release 11-19-1991
/****************************************************************************
Microsoft RPC Version 1.0 Alpha
October 1991
Adder1 Example
FILE: adder1\client.c
USAGE: client <servername>
where <servername> is the name of the server running the
server side of the distributed application
PURPOSE: Client side of RPC distributed application adder1
FUNCTIONS: main() - calls remote procedure AdderProc1
COMMENTS:
This version of the distributed application that adds two
short integers features a client that manages its connection
to the server. It uses the binding handle hRpcAdder1.
****************************************************************************/
#include <stdio.h> // printf
#include <string.h> // strlen
#include <stdlib.h> // exit
#include <rpc.h> // RPC API functions, types
#include "adder1.h" // RPC data for this interface
#define MAXPATH 300 // arbitrary large size for server, pipe path
void main(int argc, char **argv)
{
RPC_STATUS status; // returned by RPC API function
char * pszRpcPort = "adder1";
char szServerPath[MAXPATH]; // complete path
short sAdderResult;
/* Select named pipes as the transport type and provide the */
/* path to the server and named pipe that is used for RPC. */
/* The client specifies the local pipe name in the form: */
/* \device\namedpipe\pipename */
/* The client specifies the remote pipe name in the form: */
/* \device\lanmanredirector\servername\pipe\pipename */
/* In this example, the pipename is "adder1" */
if (argc == 2) {
strcpy(szServerPath, "\\device\\lanmanredirector\\");
strcat(szServerPath, argv[1]); // servername
strcat(szServerPath, "\\pipe\\");
strcat(szServerPath, pszRpcPort);
}
else {
strcpy(szServerPath, "\\device\\namedpipe\\");
strcat(szServerPath, pszRpcPort);
}
adder1_ProtocolStack.TransportType = RPC_TRANSPORT_NAMEPIPE;
adder1_ProtocolStack.TransportInfo = szServerPath;
adder1_ProtocolStack.TransportInfoLength = \
strlen(szServerPath) + 1; // add 1 for terminating null
/* Call the Microsoft RPC V1.0 Alpha API function that allows */
/* the client to establish a connection with the server. */
/* NOTE: This function will probably be replaced in future */
/* releases by the standard DCE RPC function. */
status = RpcBindToInterface(&adder1_ProtocolStack,
0L,
&hrpcAdder1);
if (status) {
printf("RpcBindToInterface returned 0x%x\n", status);
printf("%s length = %d\n", adder1_ProtocolStack.TransportInfo,
adder1_ProtocolStack.TransportInfoLength);
exit(2);
}
sAdderResult = AdderProc1(1, 2); // call the remote procedure
printf("result from remote procedure = %d\n", sAdderResult);
status = RpcUnbind(hrpcAdder1); // remote calls complete; unbind
if (status) {
printf("RpcUnbind returned 0x%x\n", status);
exit(2);
}
exit(0);
} /* end main() */
/* end adder1\client.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.