cal.x
struct variable
{
int x;
int y;
int ans;
int choice;
};
program calc_prg
{
version calc_version
{
int calc(variable)=1;
}=1;
}=0x32345676;
cal_server.c
#include "cal.h"
int *
calc_1_svc(variable *argp, struct
svc_req *rqstp)
{
static int result;
switch(argp->choice)
{
case 1:
{
result=(argp->x)+(argp->y);
break;
}
case 2:
{
result=(argp->x)*(argp->y);
break;
}
case 3:
{
result=(argp->x)-(argp->y);
break;
}
case 4:
{
result=(argp->x)/(argp->y);
break;
}
}
return &result;
}
cal_client.c
#include "cal.h"
void calc_prg_1(char *host)
{
CLIENT *clnt;
int
*result_1;
variable calc_1_arg;
clnt = clnt_create (host, calc_prg,
calc_version, "udp");
if (clnt == NULL) {
clnt_pcreateerror (host);
exit (1);
}
printf("enter choice :\n1
addition \n2.multiplication \n3.subtraction \n4. division");
scanf("%d",&calc_1_arg.choice);
printf("enter values");
scanf("%d
%d",&calc_1_arg.x,&calc_1_arg.y);
result_1 = calc_1(&calc_1_arg,
clnt);
if (result_1 == (int *) NULL) {
clnt_perror (clnt, "call
failed");
}
printf("ur result is
%d\n",*result_1);
clnt_destroy (clnt);
}
int main (int argc, char *argv[])
{
char *host;
if (argc < 2) {
printf ("usage: %s
server_host\n", argv[0]);
exit (1);
}
host = argv[1];
calc_prg_1 (host);
exit (0);
}
0 comments:
Post a Comment