|
|
1.1 root 1: /****************************************************************************
2: Microsoft RPC Version 1.0 Alpha
3: October 1991
4: Hello2 Example
5:
6: FILE: hello2\server.c
7: USAGE: server
8: PURPOSE: Server side of RPC distributed application hello2
9: FUNCTIONS: main() - registers server as RPC server
10: COMMENTS:
11: This version of the distributed application that prints
12: "hello, world" on the server features a client that
13: manages its connection to the server. It uses the binding
14: handle hRpcHello, defined in the file hello2.h.
15: ****************************************************************************/
16: #include <stdlib.h>
17: #include <windows.h>
18: #include <string.h>
19: #include <stdio.h>
20: #include <ctype.h>
21:
22: #include <rpc.h> // RPC data structures and APIs
23: #include "hello2.h" // interface
24:
25: void main(void)
26: {
27: RPC_HANDLE Server, Address, Interface;
28: RPC_STATUS status;
29:
30:
31: /* Select named pipes as the transport type and provide the */
32: /* name of the named pipe that is used for RPC. */
33: /* The server specifies the pipe name in the form: */
34: /* \device\namedpipe\pipename */
35: /* In this example, the pipename is "hello2" */
36:
37: hello2_ProtocolStack.TransportType = RPC_TRANSPORT_NAMEPIPE;
38: hello2_ProtocolStack.TransportInfo = "\\device\\namedpipe\\hello2";
39: hello2_ProtocolStack.TransportInfoLength = \
40: strlen(hello2_ProtocolStack.TransportInfo) + 1;
41:
42: status = RpcCreateServer( (RPC_EVENT_HANDLERS *)0,
43: &Server);
44: if (status) {
45: printf("RpcCreateServer: 0x%x\n", status);
46: exit(2);
47: }
48:
49: status = RpcAddAddress(Server,
50: &hello2_ProtocolStack,
51: 0, // address flags
52: &Address,
53: (void *) 0, // reserved
54: RpcNormalResourceUsage,
55: 0L); // timeout
56: if (status) {
57: printf("RpcAddAddress: 0x%x\n", status);
58: exit(2);
59: }
60:
61: status = RpcAddInterface(Server,
62: &hello2_ProtocolStack,
63: &Interface,
64: (void *) 0, // reserved
65: &hello2_DispatchTable);
66: if (status) {
67: printf("RpcAddInterface: 0x%x\n", status);
68: exit(2);
69: }
70:
71: printf("hello2 server started. Waiting for client requests...\n");
72:
73: while (1)
74: Sleep(5000);
75:
76: } /* end main() */
77:
78: /* end hello2\server.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.