getservbyname_r

Name

getservbyname_r -- retrieve information from the network services database by service name, reentrantly

Synopsis

#include <netdb.h>

int getservbyname_r(const char * name, const char * proto, struct servent * result_buf, char * buf, size_t buflen, struct servent * * result);

Description

The getservbyname_r() function is a reentrant version of the getservbyname() function.

The getservbyname_r() function shall search the network services database for an entry with the name name. The proto parameter shall restrict the search to entries with the specified protocol. If proto is NULL, getservbyname_r() may return entries with any protocol.

If a matching entry is found in the database, this function shall copy the relevant information to the application-supplied servent 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 servent 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 getservbyname_r() function shall return zero. If the return value was ERANGE, the size of the buffer buf, indicated by buflen, was too small.