second.x
struct add
{
int a;
int b;
};
program second
{
version ver
{
int sum(add)=1;
}=1;
}=0x33000000;
second_client.c
/* This is sample code generated by rpcgen. These are only templates and you can
use them as a guideline for developing your own functions. */
#include “second.h”
#include “second_clnt.c” // *** first modification ***********
void
second_1(char *host)
{
CLIENT *clnt;
int *result_1;
add sum_1_arg;
printf(“Enter Two Numbers\n”); // *** second modification ***********
scanf(“%d%d”, &sum_1_arg.a, &sum_1_arg.b);
#ifndef DEBUG
clnt = clnt_create (host, second, ver, “udp”);
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
#endif /* DEBUG */
result_1 = sum_1(&sum_1_arg, clnt);
if (result_1 == (int *) NULL) {
clnt_perror (clnt, “call failed”);
}
#ifndef DEBUG
clnt_destroy (clnt);
#endif /* DEBUG */
}
int
main (int argc, char *argv[])
{
char *host;
if (argc < 2) {
printf (“usage: %s server_host\n”, argv[0]);
exit (1);
}
host = argv[1];
second_1 (host);
exit (0);
}
second_server.c
/* This is sample code generated by rpcgen. These are only templates and you can
use them as a guideline for developing your own functions. */
#include “second.h”
#include “second_svc.c”
int * sum_1_svc(add *argp, struct svc_req *rqstp)
{
static int result;
result=(*argp).a+(*argp).b;
printf(“Addition=%d\n”,result);
return &result;
}
Leave a comment