SiddharthShah 1032221195 DivC 50 DC LabAssignment3
SiddharthShah 1032221195 DivC 50 DC LabAssignment3
struct numbers{
int a;
int b;
};
program ADD_PROG{
version ADD_VERS{
int add(numbers)=1;
}=1;
}=0x4562877;
/*
* 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 "add.h"
int *
add_1_svc(numbers *argp, struct svc_req *rqstp)
{
static int result;
return &result;
}
#include "add.h"
#include <stdio.h>
#include <stdlib.h>
void
add_prog_1(char *host, int x, int y) //++
{
CLIENT *clnt;
int *result_1;
numbers add_1_arg;
#ifndef DEBUG
clnt = clnt_create(host, ADD_PROG, ADD_VERS, "udp");
if (clnt == NULL) {
clnt_pcreateerror(host);
exit(1);
}
#endif /* DEBUG */
add_1_arg.a = x; //++
add_1_arg.b = y; //++
result_1 = add_1(&add_1_arg, clnt);
if (result_1 == (int *) NULL) {
clnt_perror(clnt, "call failed");
} else {
printf("result: %d\n", *result_1); //++
}
#ifndef DEBUG
clnt_destroy(clnt);
#endif /* DEBUG */
}
int
main(int argc, char *argv[])
{
char *host;
if (argc < 4) {
printf("usage: %s server_host x y\n", argv[0]);
exit(1);
}
host = argv[1];
add_prog_1(host, atoi(argv[2]), atoi(argv[3]));
exit(0);
}
# Parameters
CLIENT = add_client
SERVER = add_server
SOURCES_CLNT.c =
SOURCES_CLNT.h =
SOURCES_SVC.c =
SOURCES_SVC.h =
SOURCES.x = add.x
# Targets
$(TARGETS) : $(SOURCES.x)
rpcgen $(RPCGENFLAGS) $(SOURCES.x)
$(CLIENT) : $(OBJECTS_CLNT)
$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) $(LDLIBS)
$(SERVER) : $(OBJECTS_SVC)
$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)
clean:
$(RM) core $(TARGETS) $(OBJECTS_CLNT) $(OBJECTS_SVC) $(CLIENT) $(SERVER)
---------------------------------------------------------------------------------------------
mtech@MITWPUMTECH:~$ cd Desktop
mtech@MITWPUMTECH:~/Desktop$ cd rpc50
mtech@MITWPUMTECH:~/Desktop/rpc50$ sudo ./add_client
usage: ./add_client server_host x y
mtech@MITWPUMTECH:~/Desktop/rpc50$ sudo ./add_client 127.0.0.1 5 5
result: 10
----------------------------------------------------------------------------------------------