Professional Documents
Culture Documents
Distributed Computing
Distributed Computing
0801IT211090
LAB ASSIGNMENT 5
Q. Write and test a Sample “Hello World” RPC application in a procedural language such as C.
There should be a remote procedural call which should display “Hello World&” as the
output.
CODE:
hello.x
program HELLOPROG {
version HELLOVERSION {
string say_hello() = 1;
} = 1;
} = 0x31234567;
pmap_unset(HELLOPROG, HELLOVERSION);
if (strcmp(argv[1], "tcp") == 0) {
if (!svc_create(say_hello_svc, HELLOPROG, HELLOVERSION, "tcp")) {
fprintf(stderr, "Unable to create TCP service.\n");
exit(1);
Ujjwal Singh
0801IT211090
}
} else {
if (!svc_create(say_hello_svc, HELLOPROG, HELLOVERSION, "udp")) {
fprintf(stderr, "Unable to create UDP service.\n");
exit(1);
}
}
svc_run();
fprintf(stderr, "Error: svc_run() returned\n");
exit(1);
}
if (argc != 2) {
fprintf(stderr, "Usage: %s <server>\n", argv[0]);
exit(1);
}
server = argv[1];
clnt_destroy(cl);
return 0;
}
OUTPUT: