.\" Modified Mon Apr 22 01:50:54 1996 by Martin Schulze <joey@infodrom.north.de>
.\" 2001-07-25 added a clause about NULL proto (Martin Michlmayr or David N. Welton)
.\"
-.TH GETSERVENT 3 2001-07-25 "GNU" "Linux Programmer's Manual"
+.TH GETSERVENT 3 2008-08-13 "GNU" "Linux Programmer's Manual"
.SH NAME
getservent, getservbyname, getservbyport, setservent, endservent \-
get service entry
.SH DESCRIPTION
The
.BR getservent ()
-function reads the next line from the file
-\fI/etc/services\fP and returns a structure \fIservent\fP containing
-the broken out fields from the line.
-The \fI/etc/services\fP file
-is opened if necessary.
+function reads the next entry from the services database (see
+.BR services (5))
+and returns a \fIservent\fP structure containing
+the broken-out fields from the entry.
+A connection is opened to the database if necessary.
.PP
The
.BR getservbyname ()
function returns a \fIservent\fP structure
-for the line from \fI/etc/services\fP that matches the service
-\fIname\fP using protocol \fIproto\fP.
+for the entry from the database
+that matches the service \fIname\fP using protocol \fIproto\fP.
If \fIproto\fP is NULL, any protocol will be matched.
+A connection is opened to the database if necessary.
.PP
The
.BR getservbyport ()
function returns a \fIservent\fP structure
-for the line that matches the port \fIport\fP given in network byte order
+for the entry from the database
+that matches the port \fIport\fP (given in network byte order)
using protocol \fIproto\fP.
If \fIproto\fP is NULL, any protocol will be matched.
+A connection is opened to the database if necessary.
.PP
The
.BR setservent ()
-function opens and rewinds the
-\fI/etc/services\fP file.
-If \fIstayopen\fP is true (1), then the
-file will not be closed between calls to
-.BR getservbyname ()
-and
-.BR getservbyport ().
+function opens a connection to the database,
+and sets the next entry to the first entry.
+If \fIstayopen\fP is non-zero,
+then the connection to the database
+will not be closed between calls to one of the
+.BR getserv* ()
+functions.
.PP
The
.BR endservent ()
-function closes \fI/etc/services\fP.
+function closes the connection to the database.
.PP
The \fIservent\fP structure is defined in \fI<netdb.h>\fP as follows:
.sp
The official name of the service.
.TP
.I s_aliases
-A zero terminated list of alternative names for the service.
+A NULL-terminated list of alternative names for the service.
.TP
.I s_port
The port number for the service given in network byte order.