Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ypserv(1M)

services(4)

ypfiles(4)

getservent(3N)

Requires Optional LAN/X.25 Software

NAME

getservent, getservbyport, getservbyname, setservent, endservent − get service entry

SYNOPSIS

#include <netdb.h>

struct servent ∗getservent(void);

struct servent ∗getservbyname(

const char ∗name,
const char ∗proto);

struct servent ∗getservbyport(int port, const char ∗proto);

int setservent(int stayopen);

int endservent(void);

DESCRIPTION

getservent, getservbyname, and getservbyport each return a pointer to a structure of type servent containing the broken-out fields of a line in the network services data base, /etc/services. 

The members of this structure are:

s_name The official name of the service. 

s_aliases A null-terminated list of alternate names for the service. 

s_port The port number at which the service resides. 

s_proto The name of the protocol to use when contacting the service. 

getservent reads the next line of the file, opening the file if necessary. 

setservent opens and rewinds the file.  If the stayopen flag is non-zero, the services data base is not closed after each call to getservent (either directly or indirectly through getserv∗ calls). 

endservent closes the file. 

getservbyname and getservbyport sequentially search from the beginning of the file until a matching service name (among either the official names or the aliases) or port number is found, or until EOF is encountered.  If a non- NULL protocol name is also supplied (for example "tcp" or "udp"), searches must also match the protocol. 

If the system is running Network Information Service (NFS), getservbyname gets the service information from the NIS server (see ypserv(1M) and ypfiles(4)).

RETURN VALUE

getservent, getservbyname, and getservbyport return a null pointer (0) on EOF or when they are unable to open /etc/services. 

WARNINGS

All information is contained in a static area so it must be copied if it is to be saved. 

AUTHOR

getservent was developed by the University of California, Berkeley. 

FILES

/etc/services

SEE ALSO

ypserv(1M), services(4), ypfiles(4). 

Hewlett-Packard Company  —  HP-UX Release 8.05: June 1991

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026