|
|
Microsoft Windows NT Pre-Release 11-19-1991
/****************************************************************************
Microsoft RPC Version 1.0 Alpha
October 1991
Hello3 Example
FILE: hello3\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 hello3
FUNCTIONS: main() - binds to server,
calls remote procedure HelloProc2
COMMENTS:
This distributed application prompts the user for a string and
calls a remote procedure that displays that string. The client
manages its connection to the server using the binding handle
hRpcHello that is defined in the file hello3.h (from hello3.acf).
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <rpc.h> // RPC API functions, types
#include "hello3.h" // RPC data for this interface
#define MAXSTRING 300 // arbitrary large string size
void main(int argc, char **argv)
{
RPC_STATUS status; // returned by RPC API function
char * pszRpcPort = "hello3";
char szServerPath[MAXSTRING]; // complete path
char szString[MAXSTRING]; // message to server
/* 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 "hello3" */
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);
}
hello3_ProtocolStack.TransportType = RPC_TRANSPORT_NAMEPIPE;
hello3_ProtocolStack.TransportInfo = szServerPath;
hello3_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(&hello3_ProtocolStack,
0L,
&hrpcHello);
if (status) {
printf("RpcBindToInterface returned 0x%x\n", status);
printf("%s length = %d\n", hello3_ProtocolStack.TransportInfo,
hello3_ProtocolStack.TransportInfoLength);
exit(2);
}
printf("Enter a string to send to the server: ");
gets(szString);
HelloProc3(szString); // call the remote procedure
status = RpcUnbind(hrpcHello); // remote calls complete; unbind
if (status) {
printf("RpcUnbind returned 0x%x\n", status);
exit(2);
}
exit(0);
} /* end main() */
/* end hello3\client.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.