getservent(3) — Subroutines
OSF — Environment_Note_Added
NAME
getservent − Gets services file entry
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <netdb.h> struct servent ∗getservent ( void );
DESCRIPTION
The getservent() (get service entry) function opens and reads the next line of the /etc/services file.
An application program can use the getservent() function to retrieve information about network services and the protocol ports they use.
The getservent() function returns a pointer to a servent structure, which contains fields for a line of information from the /etc/services file. The servent structure is defined in the netdb.h header file.
The /etc/services file remains open after a call by the getservent() function. To close the /etc/services file after each call, use the setservent() function. Otherwise, use the endservent() function to close the /etc/services file.
NOTES
The return value points to static data that is overwritten by subsequent calls.
RETURN VALUES
Upon successful completion, the getservent() function returns a pointer to a servent structure.
If an error occurs or the end of the file is reached, the getservent() function returns a null pointer.
FILES
/etc/services
The DARPA Internet network service-name database. Each record in the file occupies a single line and has four fields consisting of the official service name, port number, protocol name, and aliases.
ENVIRONMENT NOTES
This section describes system features that are not generic to OSF/1 but that are provided in this OSF/1 implementation.
Digital Extensions
The system searches either the local /etc/services file or the NIS distributed networks file for the requested information. To determine which file or files to search, and in which order, the system uses the switches in the /etc/svc.conf file.
RELATED INFORMATION
Functions: getservbyport(3), getservbyname(3), endservent(3), setservent(3), getprotoent(3), getprotobynumber(3), getprotobyname(3), setprotoent(3), endprotoent(3)