[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1 Miscellaneous Utility Functions


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1 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.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.2 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(), @ref{rpc Data Base File Format, @file{rpc}}, @ref{rpcinfo Manual Page, @code{rpcinfo}}.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.3 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(), @ref{rpc Data Base File Format, @file{rpc}}, @ref{rpcinfo Manual Page, @code{rpcinfo}}.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.4 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.


[Top] [Contents] [Index] [ ? ]

About This Document

This document was generated on December 7, 2024 using texi2html 5.0.

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ << ] FastBack Beginning of this chapter or previous chapter 1
[ < ] Back Previous section in reading order 1.2.2
[ Up ] Up Up section 1.2
[ > ] Forward Next section in reading order 1.2.4
[ >> ] FastForward Next chapter 2
[Top] Top Cover (top) of document  
[Contents] Contents Table of contents  
[Index] Index Index  
[ ? ] About About (help)  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:


This document was generated on December 7, 2024 using texi2html 5.0.