Establishes a mapping between the program, version, netconfig structure and the service address.
Network Services Library (libnsl.a)
#include <rpc/rpc.h>
bool_t rpcb_set(prognum, progver, nconf, svcaddr)
const rpcprog_t prognum;
const rpcvers_t progver;
const struct netconfig *nconf;
struct netbuf *svcaddr
Item | Description |
---|---|
prognum | Specifies the program number of the remote program. |
progver | Specifies the version number of the remote program. |
nconf | Specifies the protocol associated with the service. |
svcaddr | Specifies the address of the remote service. |
Item | Description |
---|---|
TRUE | successful |
FALSE | unsuccessful |
The rpcb_set subroutine returns failure if one or more of the following codes are true.
Item | Description |
---|---|
RPC_UNKNOWNPROTO | The value of the netconfig argument is not valid. |
RPC_UNKNOWNADDR | The remote service address is not valid. |
#include <stdlib.h>
#include <rpc/rpc.h>
int main()
{
rpcprog_t PROGNUM ;
rpcvers_t PROGVER ;
struct netconfig *nconf ;
struct netbuf *nbuf;
struct t_bind *bind_addr = NULL;
/* Get netconfig structure corresponding to tcp transport */
if ((nconf = getnetconfigent("tcp")) == (struct netconfig *) NULL)
{
fprintf(stderr, "getnetconfigent failed");
exit(1);
}
/*
* Code to open and bind file descriptor to bind_addr address
*/
nbuf = &bind_addr->addr;
if( rpcb_set(PROGNUM, PROGVER, nconf, nbuf) == FALSE ) {
fprintf(stderr,"rpcb_set() failed");
exit(1);
}
svc_run();
return 0;
}