The getprotobyname( ), getprotobynumber( ), setprotoent( ), getprotoent( ), and endprotoent( ) functions return an entry from the PROTOSFILE (protocols) database file.
You can access this database file via the INtime Configuration utility:
#include <netdb.h> struct protoent *getprotobyname(name) char *name; struct protoent *getprotobynumber(proto) int proto; void setprotoent(stayopen) int stayopen; struct protoent *getprotoent( ) void endprotoent( )
All returned information is contained in a static area, so it must be copied if it is to be saved. Only Internet protocols are understood.
A specific entry can be retrieved by the protocol name with getprotobyname( ), or by its number with getprotobynumber( ). Both functions sequentially search the database for the specified entry. The protocol number used in the getprotobynumber( ) call should be in host order.
To retrieve a sequential series of protocol entries, it is more efficient to use the setprotoent( ), getprotoent( ), and endprotoent( ) functions. You must pair the calls to setprotoent( ) and endprotoent( ).
The setprotoent( ) function opens or rewinds (sets the file pointer to 0) the protocols database.
If passed a 0 value for the argument stayopen, setprotoent( ) opens the :config:protocols file. Subsequent calls to the getprotoent( ) function return the next entry in the protocols database until end of file, opening it if necessary. The endprotoent( ) function closes the database.
If passed a non-zero value for the argument stayopen, setprotoent( ) rewinds the :config:protocols file or opens it, if it is not already open. Subsequent calls to the getprotoent( ) function return the next entry in the protocols database until end of file, opening it if necessary. The protocols database remains open until the application executes exit( ). Calling endprotoent( ) does not close the database.
The returned protocol entry has this structure:
struct protoent { char * p_name; char ** p_aliases; unsigned long p_proto };
Where:
p_name
p_aliases
p_proto
A null pointer is returned by getprotobynumber( ), getprotobyname( ), and getprotoent( ) on an EOF or on an error.
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.1 | intime/rt/include/netdb.h | net.db.h | netiff3m.lib |