I have programed a server-client application as a RPC (low-level).
This is my server function to validate my IP address (here, just the necessary information):
int *checkip_1_svc(ip_adress *argp, struct svc_req *rqstp)
{
static int result;
struct sockaddr_in test_ip;
result =1;
return(&result);
}
Now I want to print the IP address from the connected client.
I tried:
printf("Clientadress:%s", rqstp->rq_xprt->xp_raddr.sin_addr.s_addr);
This does not work. I get a segmentation fault.
s_addrmost propably is an unsigned 32bit integer, so you might use%ubut%s:To have it printed in the
a.b.c.dnotation you might use:For details on
ntohl()please seeman ntohl().