RPC is not working after 12-13 hours on RHEL-5 ( 64 bit)
Hello,
RPC program is not working on RHEL-5 Server (64-bit). Here is the scenario.
Server is continously running and client connects and disconnects.
After 12-13 hours, client get connection timeout error 3 times and after UNKNOWN HOST Error continously.
Any help or leads to sovle this issue is greatly appreciated.
Thanks in Advance
Sekhar
--------------------------------------------------------------------
Please find the code below :
RPC PROGRAM : myhlt.x
[code]
program MYHLTPROG {
version MYHLTVERS {
int GETNODESTAT(void)=1;
}=1;
}=0x20000090;
[/code]
CLIENT PROGRAM : myhltcli.c
[code]
#include"stdio.h"
#include"rpc/rpc.h"
#include"time.h"
#include"netdb.h"
#include"sys/socket.h"
#include"netinet/in.h"
#include"arpa/inet.h"
#include "myhlt.h"
#define STIME 5
main(int argc, char *argv[])
{
CLIENT *cl;
int *result;
char *server;
char *message;
int i;
if (argc != 2) { fprintf(stderr, "usage %s host message\n",argv[0]); }
server = argv[1];
struct tm *local;
time_t t;
while(1)
{ t = time(NULL);
local = localtime(&t);
cl = clnt_create(hp->h_name, MYHLTPROG, MYHLTVERS, "tcp");
if (cl == NULL) {
/* Couldn't establish connection with server.
* Print error message and die. */
clnt_pcreateerror(server);
t = time(NULL);
local = localtime(&t);
printf("client creation is failed error is %d\n",rpc_createerr.cf_stat);
sleep(STIME);
continue;
}
result = getnodestat_1 ((void *) NULL, cl);
if (result == NULL) {
/* An error occurred while calling the server.
* Print error message and die */
clnt_perror(cl, server);
sleep(STIME);
continue;
}
/*
* Okay, we successfully called the remote procedure
*/
if (*result == 0) {
printf("couldnot connect to server\n");
sleep(STIME);
continue;
}
printf("got response from server %s!\n", server);
sleep(STIME * 2);
}
exit(0);
}
[/code]
Server Program Name : myhlt_proc.c
[code]
#include "stdio.h"
#include "rpc/rpc.h"
#include "time.h"
#include "myhlt.h"
/*
* Remote version of "printmessage"
*/
int * getnodestat_1(void *m,CLIENT *cl)
{
static int result; /* must be static! */
struct tm *local;
time_t t;
t = time(NULL);
local = localtime(&t);
printf("date and time : %s\n", asctime(local));
result = 1;
return(&result);
}
int * getnodestat_1_svc(void *m,struct svc_req *s)
{
static int result; /* must be static! */
struct tm *local;
time_t t;
t = time(NULL);
local = localtime(&t);
printf("date before client creation: %s\n", asctime(local));
result = 1;
return(&result);
}
[/code]
Make File : Makefile
[code]
ALL: rpc1 myclient myserver
rpc1: myhlt.x
rpcgen myhlt.x
myclient: myhltcli.c
cc -o mycli myhltcli.c myhlt_clnt.c
myserver:
cc -o myserver myhlt_proc.c myhlt_svc.c
clean:
rm -f *.o myhlt_xdr.c myhlt_svc.c myserver myhlt.h myhlt_clnt.c mycli
[/code]