Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

OSS Library Calls (g - h) getservbyname(3)
NAME
getservbyname - Gets a network service entry by name
LIBRARY
G-series native OSS processes: /G/system/sysnn/zinetsrl
H-series OSS processes: /G/system/zdllnnn/zinetdll
SYNOPSIS
#include <netdb.h>
struct servent *getservbyname(
const char *name,
const char *proto);
PARAMETERS
name Species the services name or the services alias name.
proto Species the name of the protocol to use when contacting the service.
DESCRIPTION
The getservbyname( ) function searches the /etc/services le sequentially for a match with the
name parameter and the proto parameter. When the proto parameter is a null pointer, any proto-
col value in the /etc/services le can match.
The getservbyname( ) function returns a pointer to a structure of type servent whose members
specify data from the /etc/services database le. The netdb.h header le denes the servent
structure.
NOTES
The getservbyname( ) return value points to static data, which is overwritten by any subsequent
calls to getservbyport(), getservbyname( ), getservent(),orsetservent().
RETURN VALUES
Upon successful completion, the getservbyname( ) function returns a pointer to a servent struc-
ture if a match is found, or a null pointer if no match is found. If the call to getservbyname()
fails, a null pointer is returned.
ERRORS
The getservbyname( ) function does not set errno.
FILES
/etc/services This is the Internet network service-name database. Each record in the le occu-
pies a single line and has four elds: the ofcial service name, the port reference,
the protocol name, and aliases.
RELATED INFORMATION
Functions: getservbyport(3), getservent(3), setservent(3), endservent(3).
Files: services(4).
527187-007 Hewlett-Packard Company 373