1836636 Members
1659 Online
110102 Solutions
New Discussion

Failure on rpc

 
siaemic
Advisor

Failure on rpc

In a C application ,we use rpc to communicate between two processes. We are experiencing a problem only on a particular new WS when the server and the client are on the same host; our doubt is that it depends on a wrong configuration.
The client performs a clnt_call towards the server; we see that the server receives the call, open a socket and try to connect to the client but gets an error "Connection Refused". In this situation on client side the clnt_call function fails for timeout.
Following is the C code of server rpc callback:
The error is on the connect function

*******************

if ((hp = gethostbyname(sgp->node)) == NULL) {
ERR("gethostbyname failed on node %s", sgp->node);
return -1;
}

sock = socket(PF_INET, SOCK_STREAM, 0);
if (sock < 0) {
ERR("socket call failed");
return -1;
}

memset(&sa, 0, sizeof (sa));
memcpy((char *)&sa.sin_addr, (char *)hp->h_addr, hp->h_length);
sa.sin_family = AF_INET;
sa.sin_port = port;

if (connect(sock, &sa, addrlen) == -1) {
ERR ("connect call failed: %s", strerror(errno));
close(sock);
return -1;
}
return sock;

***************************