1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\" Modified Sat Jul 24 19:19:11 1993 by Rik Faith (faith@cs.unc.edu)
10 .\" Modified Wed Oct 18 20:23:54 1995 by Martin Schulze <joey@infodrom.north.de>
11 .\" Modified Mon Apr 22 01:50:54 1996 by Martin Schulze <joey@infodrom.north.de>
12 .\" 2001-07-25 added a clause about NULL proto (Martin Michlmayr or David N. Welton)
14 .TH GETSERVENT 3 2021-03-22 "Linux man-pages (unreleased)"
16 getservent, getservbyname, getservbyport, setservent, endservent \-
20 .RI ( libc ", " \-lc )
25 .B struct servent *getservent(void);
27 .BI "struct servent *getservbyname(const char *" name ", const char *" proto );
28 .BI "struct servent *getservbyport(int " port ", const char *" proto );
30 .BI "void setservent(int " stayopen );
31 .B void endservent(void);
36 function reads the next entry from the services database (see
41 the broken-out fields from the entry.
42 A connection is opened to the database if necessary.
49 for the entry from the database
50 that matches the service
56 is NULL, any protocol will be matched.
57 A connection is opened to the database if necessary.
64 for the entry from the database
67 (given in network byte order)
72 is NULL, any protocol will be matched.
73 A connection is opened to the database if necessary.
77 function opens a connection to the database,
78 and sets the next entry to the first entry.
82 then the connection to the database
83 will not be closed between calls to one of the
89 function closes the connection to the database.
93 structure is defined in
100 char *s_name; /* official service name */
101 char **s_aliases; /* alias list */
102 int s_port; /* port number */
103 char *s_proto; /* protocol to use */
113 The official name of the service.
116 A NULL-terminated list of alternative names for the service.
119 The port number for the service given in network byte order.
122 The name of the protocol to use with this service.
126 .BR getservbyname (),
129 functions return a pointer to a
132 structure, or NULL if an
133 error occurs or the end of the file is reached.
137 services database file
139 For an explanation of the terms used in this section, see
147 Interface Attribute Value
151 MT-Unsafe race:servent
152 race:serventbuf locale
157 MT-Unsafe race:servbyname
163 MT-Unsafe race:servbyport
170 MT-Unsafe race:servent
181 signifies that if any of the functions
186 are used in parallel in different threads of a program,
187 then data races could occur.
189 POSIX.1-2001, POSIX.1-2008, 4.3BSD.
193 .BR getservent_r (3),