forked from JulesWang/helloworld-RPC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
37 lines (28 loc) · 610 Bytes
/
Copy pathmain.c
File metadata and controls
37 lines (28 loc) · 610 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <rpc/rpc.h>
#include "hw.h"
/*
Simple "hello world" program that demonstrates an rpc call.
*/
main (int argc, char *argv[]) {
CLIENT *cl;
char **p;
if (argc != 2) {
printf("Usage: client hostname\n");
exit(1);
}
cl = clnt_create(argv[1], HELLO_WOLRD_PROG, HELLO_WORLD_VERS, "tcp");
if (cl == NULL) {
clnt_pcreateerror(argv[1]);
exit(1);
}
printf("Getting ready to call hello world\n");
p = hw_1(NULL, cl);
printf("Back from hello world\n");
if (p == NULL) {
clnt_perror(cl,argv[1]);
exit(1);
}
printf("Returned string=%s\n", *p);
return 0;
}