Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

getservbyname(3) OSS Library Calls Reference Manual
NAME
getservbyname - Gets a network service entry by name
LIBRARY
G-series native OSS processes: /G/system/sysnn/zinetsrl
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zinetdll |
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yinetdll |
SYNOPSIS
#include <netdb.h>
struct servent *getservbyname(
const char *name,
const char *proto);
PARAMETERS
name Specifies the services name or the services alias name.
proto Specifies the name of the protocol to use when contacting the service.
DESCRIPTION
The getservbyname( ) function searches the /etc/services file 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 file 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 file defines 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 file occu-
pies a single line and has four fields: the official service name, the port reference,
the protocol name, and aliases.
RELATED INFORMATION
Functions: getservbyport(3), getservent(3), setservent(3), endservent(3).
Files: services(4).
3136 Hewlett-Packard Company 527187-017