Hii everybody
I was building RPC based server-client application
I have a struct called event contains
int type
long int time
I have a function in a server that return (*event)
event *
log_1_svc(event *argp, struct svc_req *rqstp)
{
static event* result;
result = (struct event*)malloc (3 * sizeof (struct event));
while (i <3)
{
result[i].type_id = i;
result[i].time = i;
i++;
}
return &result
}
what I want is to receive results at client using this pointer
here is the code at client's site:
log_prog_1(char *host,int client_type,int type_id,long int time)
{
event *result_1;
result_1 = log_1(&log_1_arg, clnt); // this calls the function in server and gurantee that the result is returned an address to pointer
int i =0;
while (i<3)
{
printf ("Type: %d\n",result_1[i].type_id);
printf ("Time: %ld\n",result_1[i].time);
i++;
}
this code works but it seems that it returns addresses not values (the numbers shown in client terminal is different from ones in server's terminal).
I tried to let the server return result
return result;
not the address of result (as written previously)
return &result;
it worked but only the first item printed correctly in client's terminal the other 2 items are 0's
please provide me with a solution and thanks in advance : )