File:  [WindowsNT SDKs] / mstools / samples / rpc / hello1 / 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
                               Hello1 Example
    FILE:       hello1\server.c
    USAGE:      server
    PURPOSE:    Server side of RPC distributed application hello1
    FUNCTIONS:  main() - registers server as RPC server
    COMMENTS:
    This version of the distributed application that prints
    "hello, world" on the server features automatic binding.
    The client application makes the remote call as if it
    were a local call.
****************************************************************************/
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>

#include <rpc.h>       // RPC data structures and APIs
#include "hello1.h"    // remote data and functions

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

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

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

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

    status = RpcAddInterface(Server,
                             &hello1_ProtocolStack,
                             &Interface,
                             (void *) 0,  // reserved
                             &hello1_DispatchTable);
    if (status) {
        printf("RpcAddInterface: 0x%x\n", status);
        exit(2);
    }
    printf("This application requires the locator service.\n");
    printf("The locator service is not provided with RPC V1.0 Alpha.\n");
    exit(0);

    status = RpcExport(Server,
                       RpcScopeLocal,
                       &hello1_ProtocolStack);
    if (status) {
        printf("RpcExport: 0x%x\n", status);
        exit(2);
    }

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

    while (1)
        Sleep(5000);

} /* end hello1\server.c */

unix.superglobalmegacorp.com

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