getservbyport_r

Name

getservbyport_r -- retrieve information from the network services database by service port, reentrantly

Synopsis

#include <netdb.h>

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

Description

The getservbyport_r() function is a reentrant version of the getservbyport() function.

The getservbyport_r() function shall search the network services database for an entry with the port port. The proto parameter shall restrict the search to entries with the specified protocol. If proto is NULL, getservbyport_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 getservbyport_r() function shall return zero. If the return value was ERANGE, the size of the buffer buf, indicated by buflen, was too small.