|
|
Microsoft Windows NT Pre-Release 11-19-1991
/****************************************************************************
Microsoft RPC Version 1.0 Alpha
October 1991
Hello2 Example
FILE: hello2\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 hello2
FUNCTIONS: main() - calls remote procedure HelloProc2
COMMENTS:
This version of the distributed application that prints
"hello, world" on the server features a client that
manages its connection to the server. It uses the binding
handle hRpcHello that is defined in the file hello2.h.
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <rpc.h> // RPC API functions, types
#include "hello2.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 = "hello2";
char szServerPath[MAXPATH]; // complete path
/* 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 "hello2" */
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);
}
hello2_ProtocolStack.TransportType = RPC_TRANSPORT_NAMEPIPE;
hello2_ProtocolStack.TransportInfo = szServerPath;
hello2_ProtocolStack.TransportInfoLength = \
strlen(szServerPath) + 1; // add 1 for terminating null
/* Call the Microsoft RPC V1.0 Alpha API function that lets */
/* the client establish a connection with the server. */
/* NOTE: This API function will be replaced in future */
/* releases by the standard DCE RPC function. */
status = RpcBindToInterface(&hello2_ProtocolStack,
0L,
&hrpcHello);
if (status) {
printf("RpcBindToInterface returned 0x%x\n", status);
printf("%s length = %d\n", hello2_ProtocolStack.TransportInfo,
hello2_ProtocolStack.TransportInfoLength);
exit(2);
}
HelloProc2(); // call the remote procedure
status = RpcUnbind(hrpcHello); // remote calls done; unbind
if (status) {
printf("RpcUnbind returned 0x%x\n", status);
exit(2);
}
exit(0);
} /* end \hello2\client.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.