File:  [WindowsNT SDKs] / mstools / samples / rpc / hello2 / server.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 18:20:01 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: ntsdk-oct-1991, ntsdk-dec-1991, HEAD
Microsoft Windows NT Pre-Release 11-19-1991

/****************************************************************************
                       Microsoft RPC Version 1.0 Alpha
                                October 1991
                               Hello2 Example

    FILE:       hello2\server.c
    USAGE:      server
    PURPOSE:    Server side of RPC distributed application hello2
    FUNCTIONS:  main() - registers server as RPC server
    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, defined in the file hello2.h.
****************************************************************************/
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>

#include <rpc.h>    // RPC data structures and APIs
#include "hello2.h"    // interface

void main(void)
{
    RPC_HANDLE Server, Address, Interface;
    RPC_STATUS status;


/*  Select named pipes as the transport type and provide the     */
/*  name of the named pipe that is used for RPC.                 */
/*  The server specifies the pipe name in the form:              */
/*       \device\namedpipe\pipename                              */
/*  In this example, the pipename is "hello2"                    */

    hello2_ProtocolStack.TransportType = RPC_TRANSPORT_NAMEPIPE;
    hello2_ProtocolStack.TransportInfo = "\\device\\namedpipe\\hello2";
    hello2_ProtocolStack.TransportInfoLength = \
        strlen(hello2_ProtocolStack.TransportInfo) + 1;

    status = RpcCreateServer( (RPC_EVENT_HANDLERS *)0,
                              &Server);
    if (status) {
        printf("RpcCreateServer: 0x%x\n", status);
        exit(2);
    }

    status = RpcAddAddress(Server,
                           &hello2_ProtocolStack,
                           0,            // address flags
                           &Address,
                           (void *) 0,   // reserved
                           RpcNormalResourceUsage,
                           0L);          // timeout
    if (status) {
        printf("RpcAddAddress: 0x%x\n", status);
        exit(2);
    }

    status = RpcAddInterface(Server,
                             &hello2_ProtocolStack,
                             &Interface,
                             (void *) 0,  // reserved
                             &hello2_DispatchTable);
    if (status) {
        printf("RpcAddInterface: 0x%x\n", status);
        exit(2);
    }

    printf("hello2 server started.  Waiting for client requests...\n");

    while (1)
        Sleep(5000);

} /* end main() */

/* end hello2\server.c */

unix.superglobalmegacorp.com

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