Annotation of mstools/samples/rpc/hello2/client.c, revision 1.1.1.1

1.1       root        1: /****************************************************************************
                      2:                        Microsoft RPC Version 1.0 Alpha
                      3:                                 October 1991
                      4:                                Hello2 Example
                      5: 
                      6:     FILE:       hello2\client.c
                      7:     USAGE:      client <servername>
                      8:                 where  <servername> is the name of the server running the
                      9:                 server side of the distributed application
                     10:     PURPOSE:    Client side of RPC distributed application hello2
                     11:     FUNCTIONS:  main() - calls remote procedure HelloProc2
                     12:     COMMENTS:
                     13:     This version of the distributed application that prints
                     14:     "hello, world" on the server features a client that
                     15:     manages its connection to the server. It uses the binding
                     16:     handle hRpcHello that is defined in the file hello2.h.
                     17: 
                     18: ****************************************************************************/
                     19: #include <stdio.h>
                     20: #include <string.h>
                     21: #include <stdlib.h>
                     22: #include <rpc.h>       // RPC API functions, types
                     23: #include "hello2.h"    // RPC data for this interface
                     24: 
                     25: #define MAXPATH 300    // arbitrary large size for server, pipe path
                     26: 
                     27: void main(int argc, char **argv)
                     28: {
                     29:     RPC_STATUS status;             // returned by RPC API function
                     30:     char * pszRpcPort = "hello2";
                     31:     char szServerPath[MAXPATH];          // complete path
                     32: 
                     33: /*  Select named pipes as the transport type and provide the    */
                     34: /*  path to the server and named pipe that is used for RPC.     */
                     35: /*  The client specifies the local pipe name in the form:       */
                     36: /*     \device\namedpipe\pipename                               */
                     37: /*  The client specifies the remote pipe name in the form:      */
                     38: /*     \device\lanmanredirector\servername\pipe\pipename        */
                     39: /*  In this example, the pipename is "hello2"                   */
                     40: 
                     41:     if (argc == 2) {
                     42:         strcpy(szServerPath, "\\device\\lanmanredirector\\");
                     43:         strcat(szServerPath, argv[1]);      // servername
                     44:         strcat(szServerPath, "\\pipe\\");
                     45:         strcat(szServerPath, pszRpcPort);
                     46:     }
                     47:     else {
                     48:         strcpy(szServerPath, "\\device\\namedpipe\\");
                     49:         strcat(szServerPath, pszRpcPort);
                     50:     }
                     51: 
                     52:     hello2_ProtocolStack.TransportType = RPC_TRANSPORT_NAMEPIPE;
                     53:     hello2_ProtocolStack.TransportInfo = szServerPath;
                     54:     hello2_ProtocolStack.TransportInfoLength = \
                     55:         strlen(szServerPath) + 1;   // add 1 for terminating null 
                     56: 
                     57: /*  Call the Microsoft RPC V1.0 Alpha API function that lets     */
                     58: /*  the client establish a connection with the server.           */
                     59: /*  NOTE:  This API function will be replaced in future          */
                     60: /*  releases by the standard DCE RPC function.                   */
                     61: 
                     62:     status = RpcBindToInterface(&hello2_ProtocolStack,
                     63:                                 0L,
                     64:                                 &hrpcHello);
                     65:     if (status) {
                     66:         printf("RpcBindToInterface returned 0x%x\n", status);
                     67:         printf("%s length = %d\n", hello2_ProtocolStack.TransportInfo,
                     68:                 hello2_ProtocolStack.TransportInfoLength);
                     69:         exit(2);
                     70:     }
                     71: 
                     72:     HelloProc2();     // call the remote procedure
                     73: 
                     74:     status = RpcUnbind(hrpcHello);  // remote calls done; unbind
                     75:     if (status) {
                     76:         printf("RpcUnbind returned 0x%x\n", status);
                     77:         exit(2);
                     78:     }
                     79:     exit(0);
                     80: } /* end \hello2\client.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.