DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

getprotoent(3N)


getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent -- get protocol entry

Synopsis

cc [options] file -lsocket -lnsl
#include <netdb.h>

struct protoent *getprotoent(void);

struct protoent *getprotobyname(const char *name);

struct protoent *getprotobynumber(int proto);

void setprotoent(int stayopen);

void endprotoent(void);

Description

getprotoent, getprotobyname, and getprotobynumber each return a pointer to an object with the following structure containing the broken-out fields of a line in the network protocol database.

The protoent structure include the following members:

   char   *p_name;        /* official name of protocol */
   char   **p_aliases;    /* alias list */
   int    p_proto;        /* protocol number */

The members of this structure are:


p_name
the official name of the protocol

p_aliases
a zero terminated list of alternate names for the protocol

p_proto
the protocol number

getprotoent reads the next line of the database, opening it if necessary.

setprotoent opens and rewinds the database. If the stayopen flag is non-zero, the net data base will not be closed after each call to getprotoent (either directly, or indirectly through one of the other getproto calls).

endprotoent closes the database.

getprotobyname and getprotobynumber sequentially search from the beginning of the database until a matching protocol name or protocol number is found, or until an EOF is encountered.

Files


/etc/protocols

/var/yp/{domainname}/protocols.byname

/var/yp/{domainname}/protocols.bynumber

Return values

A NULL pointer is returned on an EOF or error.

References

protocols(4tcp), ypserv(1Mnis)

Notices

All information is contained in a static area so it must be copied if it is to be saved. For multi-threaded applications, this must be done on a per-thread basis.

Functions that provide successive entries in files on successive calls must be called from a single thread.

Only the Internet protocols are currently understood.

These functions use the name-to-address resolution mechanism described in netdir(3N) and netconfig(4bnu). This mechanism may use a local database or the services of Network Information Service (NIS) or Domain Name Service (DNS).


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004