getprotobynumber(), getprotobyname(), getprotoent(), setprotoent(), endprotoent() - get protocol entry
#include <netdb.h>
struct protoent * getprotobyname (const char *name)
struct protoent * getprotobynumber (int proto)
struct protoent * getprotoent (void)
void setprotoent (int stayopen)
void endprotoent (void)
The getprotobyname(2) and getprotobynumber(2) functions each return a pointer to an object with the following structure containing the information from a network protocol database.
struct protoent {
char * p_name; /* official name of protocol */
char ** p_aliases; /* alias list */
int p_proto; /* protocol number */
};
The members of this structure are:
The getprotobyname(2) function and getprotobynumber(2) sequentially search from the beginning of the file until a matching protocol name or protocol number is found, or until EOF is encountered.
The getprotoent(2), setprotoent(2), and endprotoent(2) functions also deal with the network database, but on an entry-by-entry basis. The getprotoent(2) call reads the next line of the file, opening the file if necessary. The setprotoent(2) call opens and rewinds the file. If the stayopen flag is non-zero, the network database stays open after each call to getprotobyname(2) or getprotobynumber(2). (The default action is to close the database after these calls.) The endprotoent(2) call closes the file.
The functions getprotoent(2), getprotobyname(2), and getprotobynumber(2) return pointers to protoent structures.
All of the function return NULL on failure.
These functions use a static data space; if the data is needed for future use, it should be copied before any subsequent calls overwrite it. Only the Internet protocols are currently available.
The INTERIX sockets implementation is built around the Microsoft Winsock DLL; to configure the protocols appropriately, see the documentation for configuring your Windows network.
protocols(5)