Miscellaneous Utility Functions
===============================

bindresvport()
--------------

Bind a socket to a privileged IP port.

     #include <sys/types.h>
     #include <netinet/in.h>

     int
     bindresvport(sd, sin)
     int sd;
     struct sockaddr_in *sin;

bindresvport() is used to bind a socket descriptor to a privileged IP port, that is, a port number in the range 0-1023.  The routine returns 0 if it is successful, otherwise -1 is returned and errno set to reflect the cause of the error.  Only root can bind to a privileged port; this call will fail for any other users.

getrpcbyname()
--------------

Get an RPC entry.

     #include <netdb.h>

     struct rpcent *
     getrpcbyname(name)
     char *name;

Return a pointer to an object with the following structure containing the broken-out fields of a line in the rpc program number data base, AmiTCP:db/rpc.

     struct    rpcent {
        char *r_name;       /* name of server for this rpc program */
        char **r_aliases;   /* alias list */
        long r_number;      /* rpc program number */
     };

The members of this structure are:

r_name
     The name of the server for this rpc program.

r_aliases
     A zero terminated list of alternate names for the rpc program.

number
     The rpc program number for this service.

getrpcbyname() sequentially searches from the beginning of the file until a matching rpc program name is found, or until end-of-file is encountered.

A NULL pointer is returned on EOF or error.

NOTE: All information is contained in a static area so it must be copied if it is to be saved.

See also:
=========

getrpcbynumber(), rpc, rpcinfo.

getrpcbynumber()
----------------

Get an RPC entry.

     #include <netdb.h>

     struct rpcent *
     getrpcbynumber(number)
     int number;

Return a pointer to an object with the following structure containing the broken-out fields of a line in the rpc program number data base, AmiTCP:db/rpc.

     struct    rpcent {
        char *r_name;       /* name of server for this rpc program */
        char **r_aliases;   /* alias list */
        long r_number;      /* rpc program number */
     };

The members of this structure are:

r_name
     The name of the server for this rpc program.

r_aliases
     A zero terminated list of alternate names for the rpc program.

number
     The rpc program number for this service.

getrpcbynumber() sequentially searches from the beginning of the file until a matching rpc program number is found, or until end-of-file is encountered.

A NULL pointer is returned on EOF or error.

NOTE: All information is contained in a static area so it must be copied if it is to be saved.

See also:
=========

getrpcbyname(), rpc, rpcinfo.

getrpcport()
------------

Get RPC port number.

     int
     getrpcport(host, prognum, versnum, proto)
     char *host;
     int prognum, versnum, proto;

Returns the port number for version versnum of the RPC program prognum running on host and using protocol proto.  It returns 0 if it cannot contact the portmapper, or if prognum is not registered.  If prognum is registered but not with version versnum, it will still return a port number (for some version of the program) indicating that the program is indeed registered.  The version mismatch will be detected upon the first call to the service.