#include <netdb.h> int getservent_r(struct servent *servent_struct_addr, struct servent_data *servent_data_struct_addr)
The getservent_r() function is used to retrieve information about services: the protocol being used by the service and the port number assigned for the service. The information is retrieved from the services database file. When the getservent_r() is first called, the file is opened, and the first entry is returned. Each subsequent call of getservent_r() results in the next entry in the file being returned. To close the file, use endservent_r().
No authorization is required.
The getservent_r() function returns an integer. Possible values are:
The struct servent denoted by servent_struct_addr and struct servent_datadenoted by servent_data_struct_addr are both defined in <netdb.h>. The structure struct serventis defined as:
struct servent [ char *s_name; char **s_aliases; int s_port; char *s_proto ];
s_name points to the character string that contains the name of the service. s_aliases is a pointer to a NULL-terminated list of pointers, each of which points to a character string that represents an alternative name for the service. s_port is the port number assigned to the service. s_proto is a pointer to a character string that contains the name of the protocol being used by the service.
When the getservent_r() function fails, errno can be set to:
The servent_data structure was not properly initialized with hexadecimal zeros before initial use. For corrective action, see the description for structure servent_data.
The iSeries Navigator or the following CL commands can be used to access the services database file:
A coded character set identifier (CCSID) of 65535 for the job requests that no database translation be performed. For translation to occur for the service names returned in the servent structure, the job CCSID must be something other than 65535.
Top | UNIX-Type APIs | APIs by category |