getprotobynumber_r -- retrieve information from the network protocol database by protocol number, reentrantly


#include <netdb.h>

int getprotobynumber_r(int proto, struct protoent * result_buf, char * buf, size_t buflen, struct protoent * * result);


The getprotobynumber_r() function is a reentrant version of the getprotobynumber() function.

The getprotobynumber_r() function shall search the network protocol database for an entry with protocol number proto.

If a matching entry is found in the database, this function shall copy the relevant information to the application-supplied protoent structure referenced by result_buf, and return a pointer to this structure in *result. If no matching entry is found, *result shall be set to a null pointer.

The array buf shall contain the string fields referenced by the protoent structure that was returned. The parameter buflen shall specify the array's size. 1024 bytes should be enough for most uses.

Return Value

On success, the getprotobynumber_r() function shall return 0. If the return value was ERANGE, the size of the buffer buf, indicated by buflen, was too small.