Returns the port number on which the specified service is waiting. Format #include <rpc/pmap_clnt.h> u_short pmap_getport(struct sockaddr_in *addr, u_long prognum, u_long versnum, u_long protocol );
1 – Arguments
addr A pointer to a sockaddr_in structure containing the Internet address of the host where the remote Portmapper resides. prognum The program number associated with the remote procedure. versnum The version number associated with the remote procedure. protocol The transport protocol that the remote procedure uses. Specify either IPPROTO_UDP or IPPROTO_TCP.
2 – Description
A client interface to the Portmapper. This routine returns the port number on which waits a server that supports program number prognum, version versnum, and speaks the transport protocol associated with protocol (IPPROTO_UDP or IPPROTO_TCP). NOTES If the requested version is not available, but at least the requested program is registered, the routine returns a port number. The pmap_getport routine returns the port number in host byte order not network byte order. For certain routines you may need to convert this value to network byte order using the htons routine. For example, the sockaddr_in structure requires that the port number be in network byte order.
3 – Return Values
x The port number of the service on the remote system. 0 No mapping exists or RPC could not contact the remote Portmapper service. In the latter case, the global variable rpc_createerr.cf_error contains the ONC RPC status.