Gives the network address of a caller of a procedure (a server-side subroutine).
Network Services Library (libnsl.a)
The svc_getrpccaller subroutine gives network address of a caller of a procedure associated with the remote procedure call (RPC) service handle.
Item | Description |
---|---|
xprt | Represents the RPC service handle. |
On successful completion, the svc_getrpccaller subroutine returns network address of a caller.
#include <stdlib.h>
#include <rpc/rpc.h>
#define PROG 0x3fffffffL
#define VERS 0x1L
static void sample_dispatch();
main()
{
char *nettype;
int no_of_handles;
nettype = "tcp";
/* Create RPC service handle and register with RPCBIND service */
if((no_of_handles = svc_create(sample_dispatch, PROG, VERS,nettype)) == 0)
{
fprintf(stdout,"Error in svc_create!");
exit(EXIT_FAILURE);
}
svc_run();
return 0;
}
/* following is the sample dispatch routine*/
static void sample_dispatch(struct svc_req *request, SVCXPRT *xprt)
{
int result;
struct netbuf *clntaddr;
/* Get client's name and address */
clntaddr = svc_getrpccaller(xprt);
/* send reply back to client */
}