Annotation of mstools/samples/rpc/hello3/client.c, revision 1.1

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

unix.superglobalmegacorp.com

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