Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

RPC program problem!

$
0
0

Hi,

I'm working on RPC in linux , I use Rpcgen to generate the files . My program is to send an array to a server , the server returns 3 * array..

     // .x file

const maxnum=50;
struct inout_array
{
  int array<maxnum>;
 };
program MATMULT_PROG
{
  version MATMUL_VER{
  inout_array matmul(inout_array)=1;
 }=1;
}=0x23451689;
-----------------
//server.c 

#include "matmul.h"
inout_array *
matmul_1_svc(inout_array *argp, struct svc_req *rqstp)
{
static inout_array result;
inout_array x;
int i;
for (i=0;i<argp->array.array_len;i++)
result.array.array_val[i]=argp->array.array_val[i]*3;
return &result;
}
--------------------------
//client.c
#include "matmul.h"
int main (int argc, char *argv[])
{ char *host;
host = argv[1];
CLIENT *clnt;
inout_array *result_1;
inout_array matmul_1_arg;
int i;
int a[maxnum]; //passed array to server
int tindex=4;
for(i=0;i<argc-2;i++) a[i]="atoi(argv[tindex++]);" matmul_1_arg.array.array_val="a;" clnt="clnt_create" (host,="" matmult_prog,="" matmul_ver,="" "tcp");="" if="" (clnt="=" null)="" {="" clnt_pcreateerror="" (host);="" exit="" (1);="" }="" result_1="matmul_1(&amp;matmul_1_arg," clnt);="" if="" (result_1="=" (inout_array="" *="" )="" null)="" {="" clnt_perror="" (clnt,="" "call="" failed");="" }="" clnt_destroy="" (clnt);="" for(i="0;i&lt;result_1-">array.array_len;i++)
printf("%d\n",result_1->array.array_val[i]);
exit (0);
}



I don't know what goes wrong here!

Thanks a lot!

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>