|
Description
The getprotobyname(), getprotobynumber() and getprotoent() functions return information about the available services. These functions access the file /etc/inet/protocols. The interface is provided for compatibility reasons. The contents of the file are coded in EBCDIC.
The getprotobyname(), getprotobynumber() and getprotoent() functions return a pointer to an object with the protoent structure described below.
The protoent structure corresponds to the fields of a line in the protocol /etc/inet/protocols database and is declared as follows:
struct protoent { char *p_name; /* Official name of the protocol*/ char **p_aliases; /* Alias list */ int p_proto; /* Protocol number */ };
Components of the protoent structure:
p_name | Name of the protocol. |
p_aliases | A list of alternative (alias) names for the protocol, terminated with null. |
p_proto | Number of the protocol. |
getprotoent() reads the next line from the file. If necessary, getprotoent() opens the file first.
getprotoent() opens the file and resets it to the start. If the stayopen flag is not equal to zero, the database is not closed after any getprotoent() call (neither directly nor indirectly via one of the other getproto...() calls).
endprotoent() closes the file.
getprotobyname() and getprotobynumber() search sequentially through the file from the start until
a matching protocol name is found or
the matching protocol number is found or
the end of the file is reached.
Return value
The null pointer is returned if the search reaches the end of the file.
Note
All information is in a static area and therefore has to be copied if it is to be saved.
File
/etc/inet/protocols