# endprotoent

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           endprotoent, getprotobyname, getprotobynumber, getprotoent,
           setprotoent — network protocol database functions
    


## SYNOPSIS



           #include <netdb.h>
    
           void endprotoent(void);
           struct protoent *getprotobyname(const char *_name_);
           struct protoent *getprotobynumber(int _proto_);
           struct protoent *getprotoent(void);
           void setprotoent(int _stayopen_);
    


## DESCRIPTION



           These functions shall retrieve information about protocols. This
           information is considered to be stored in a database that can be
           accessed sequentially or randomly. The implementation of this
           database is unspecified.
    
           The _setprotoent_() function shall open a connection to the
           database, and set the next entry to the first entry. If the
           _stayopen_ argument is non-zero, the connection to the network
           protocol database shall not be closed after each call to
           _getprotoent_() (either directly, or indirectly through one of the
           other _getproto*_() functions), and the implementation may maintain
           an open file descriptor for the database.
    
           The _getprotobyname_() function shall search the database from the
           beginning and find the first entry for which the protocol name
           specified by _name_ matches the _p_name_ member, opening and closing a
           connection to the database as necessary.
    
           The _getprotobynumber_() function shall search the database from the
           beginning and find the first entry for which the protocol number
           specified by _proto_ matches the _p_proto_ member, opening and closing
           a connection to the database as necessary.
    
           The _getprotoent_() function shall read the next entry of the
           database, opening and closing a connection to the database as
           necessary.
    
           The _getprotobyname_(), _getprotobynumber_(), and _getprotoent_()
           functions shall each return a pointer to a **protoent** structure, the
           members of which shall contain the fields of an entry in the
           network protocol database.
    
           The _endprotoent_() function shall close the connection to the
           database, releasing any open file descriptor.
    
           These functions need not be thread-safe.
    


## RETURN VALUE



           Upon successful completion, _getprotobyname_(), _getprotobynumber_(),
           and _getprotoent_() return a pointer to a **protoent** structure if the
           requested entry was found, and a null pointer if the end of the
           database was reached or the requested entry was not found.
           Otherwise, a null pointer is returned.
    
           The application shall not modify the structure to which the return
           value points, nor any storage areas pointed to by pointers within
           the structure. The returned pointer, and pointers within the
           structure, might be invalidated or the structure or the storage
           areas might be overwritten by a subsequent call to
           _getprotobyname_(), _getprotobynumber_(), or _getprotoent_().  The
           returned pointer, and pointers within the structure, might also be
           invalidated if the calling thread is terminated.
    


## ERRORS



           No errors are defined.
    
           _The following sections are informative._
    


## EXAMPLES



           None.
    


## APPLICATION USAGE



           None.
    


## RATIONALE



           None.
    


## FUTURE DIRECTIONS



           None.
    


* * *