Sponsored Content
Top Forums Programming Call failed: RPC: Can't decode result Post 302992406 by mvikramreddy92 on Friday 24th of February 2017 12:54:38 PM
Old 02-24-2017
Call failed: RPC: Can't decode result

Hello I am trying to run rpc program to query an entry from a file at the server side that is in the form of
Code:
<mm> <dd>  <event>

. I get the proper result at the server. I have verified it by printf statements just before return statement of the result at server side. But somehow I am unable to catch the result at the client side. I get the following error at the client side:

Code:
$ ./client localhost query 01 01
call failed: RPC: Can't decode result
Segmentation fault (core dumped)

Server side:
Code:
$ ./server
result.event = The Epoch (Time 0 for UNIX systems, Midnight GMT) (1970)
^C

Client:

Code:
#include "hist.h"
#include <stdio.h>
#include <stdlib.h> /* getenv, exit */

void
historyprog_1(char *host, char *month, char *day)
{
    CLIENT *clnt;
    data  *result_1;
    data  query_event_1_arg;

    clnt = clnt_create(host, HISTORYPROG, HISTORYVERS_QUERY, "tcp");
    if (clnt == (CLIENT *) NULL) {
        clnt_pcreateerror(host);
        exit(1);
    }
        
    query_event_1_arg.month=month;
    query_event_1_arg.day=day;
    query_event_1_arg.event="hello";// If this line is removed I get another seg fault here
    
    result_1 = query_event_1(&query_event_1_arg, clnt);
                
    if (result_1 == (data *) NULL) {
        clnt_perror(clnt, "call failed"); 
    }
    printf("result_1->event = %s\n", result_1->event);
        
    clnt_destroy(clnt);
}


int main(int argc, char *argv[])
{
    char *host;
    char *month;
    char *day;
    char *event;

    if (argc < 2) {
        printf("usage:  %s server_host\n", argv[0]);
        exit(1);
    }
    host = argv[1];
    month = argv[3];
    day=argv[4];
    
    historyprog_1(host,month,day);
    return 0;
}

Server:
Code:
#include "hist.h"
#include <stdio.h>
#include <stdlib.h> /* getenv, exit */
#include <signal.h>
#include <string.h>

data *
query_event_1_svc(data *argp, struct svc_req *rqstp)
{
    static data result;
    FILE *f;
    char *month;
    char *day;
    char *event;
    int len; 
    int j;
    char line[265];
    char temp[265];
    
    f = fopen("in.dat", "r");
    if (f==NULL)
    {
        printf("cannot open");
    }
    
    while(fgets(line,265,f)!=NULL)
    {
        for(j=0;j<265;j++)
        {
            temp[j] = '\0';
        }
        len = strlen(line);                
        
        for(j=0;j<2;j++)
            temp[j] = line[j];
        month=strdup(temp);
                
        for(j=0;j<2;j++)
            temp[j] = line[j+3];
        day=strdup(temp);
        
        for(j=0;j<len-7;j++)
            temp[j] = line[j+6];
        event=strdup(temp);
        
        if ((strcmp(argp->month, month) == 0)&&(strcmp(argp->day, day) == 0))
        {    
            result.event = strdup(event);
            fclose(f);
            printf("result.event = %s\n", result.event);
            return (&result);    
        }
        free(month);
        free(event);
        free(day);
    }
    fclose(f);
    return (&result);
}

hist.x
Code:
struct data
{
    string month<2>;
    string day<2> ;
    string event<80>;
};
program HISTORYPROG {
    version HISTORYVERS_QUERY {
             data QUERY_EVENT(data) = 1;
       } = 1;
} = 0x20000001;

Where is it going wrong?
 

10 More Discussions You Might Find Interesting

1. Solaris

Admintool and rpc call

Hi all, I'm trying to launch admintool via an export DISPLAY. i get the message: Received communication service error 4: Remote procedure call timed out: program = 100087, version = 10 Just to say, i don't use nis/nisplus on my server... What to do? Thanx Jason (17 Replies)
Discussion started by: penguin-friend
17 Replies

2. Shell Programming and Scripting

tcsh user failed to call library in ksh program

Hi folks, I'm trying to organize functions in my ksh program into libraries. If I run my program as any ksh user it will succeed. Only when I run my program as tcsh user (i.e oracle) I failed. Example ======= The ksh code: tornado:/tmp # cat nir.ksh #! /bin/ksh cdromPath=`pwd`... (1 Reply)
Discussion started by: nir_s
1 Replies

3. Solaris

NFS write failed for server.....error 11 (RPC: Server can't decode arguments)

Hello! I have a Linux nfs server (called server100 below) with a export nfs. My problem is that the Solaris client (called client100 below) doesn't seems to like it. In the Solaris syslog I got following messages (and after a while the solaris client behave liked its hanged/to buzy). Also see... (3 Replies)
Discussion started by: sap4ever
3 Replies

4. Solaris

How to get RPC(Remote Proceedure Call) values?

Guys, Help me out in getting the RPC resource values of the system. By running the ipcs command i get the HEXA values of the IPC(Inter Process Communication) values in the system like q 12760 0x10fe4d88 --rw-rw-rw- a-1982 cts m 686089 0x10fe4d48 --rw-rw-rw- a-1982 ... (2 Replies)
Discussion started by: meheretoknow
2 Replies

5. Solaris

RPC: Rpcbind failure - RPC: Timed out

while i trying to mount from NAS i have this messages mount -F nfs -o rw 172.16.110.13:/tremabkup /tremabkup nfs mount: 172.16.110.13: : RPC: Rpcbind failure - RPC: Timed out nfs mount: retrying: /tremabkup nfs mount: 172.16.110.13: : RPC: Rpcbind failure - RPC: Timed out nfs mount:... (2 Replies)
Discussion started by: thecobra151
2 Replies

6. Solaris

RPC: Rpcbind failure - RPC: Timed out error (solaris)

C: Rpcbind failure - RPC: Timed out error (solaris) hello an nfs server on my sun fire v440 is not responding , i get the error bellow and lots of my networking services are not reponding, please helppppp its an emergency RPC: Rpcbind failure - RPC: Timed out i also get NFS server... (2 Replies)
Discussion started by: feg
2 Replies

7. UNIX for Advanced & Expert Users

System call failed with 127 .. after 500 times when called in loop

Hi Experts, I have a code like this. ===== #include.... int main() { int count = 0; while(1){ printf("\n Interation number is: %d \n ",count); rv = system(" test.sh > log.txt " ); if (-1 == rv) { printf("Could not generate static log: error... (12 Replies)
Discussion started by: binnyjeshan
12 Replies

8. Solaris

nfs mount: RPC: Rpcbind failure - RPC: Timed out

Fails to mount the server (10.125.224.22) during installation of a software on client, throwing the below error: nfs mount: 10.125.224.22: : RPC: Rpcbind failure - RPC: Timed out nfs mount: retrying: /cdrom This happened after complete shutdown of the lab. The server came up fine but most... (1 Reply)
Discussion started by: frintocf
1 Replies

9. AIX

Backup: The lseek call failed

Hi, We are facing issues while backing up our 1205 GB filesystem on LTO5 Tape. During backup the "backup: The lseek call failed." messages were generated, I want to know why these messages were generating AIX version is: 6100-08-00-0000 backup: The date of this level 0 backup is Mon Mar 11... (4 Replies)
Discussion started by: m_raheelahmed
4 Replies

10. Solaris

Rpcinfo: can't contact portmapper: RPC: Authentication error; why = Failed (unspecified error)

I have two servers with a fresh install of Solaris 11, and having problems when doing rpcinfo between them. There is no firewall involved, so everything should theoretically be getting through. Does anyone have any ideas? I did a lot of Google searches, and haven't found a working solution yet. ... (2 Replies)
Discussion started by: christr
2 Replies
All times are GMT -4. The time now is 10:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy