2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 19:19:11 1993 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified Wed Oct 18 20:23:54 1995 by Martin Schulze <joey@infodrom.north.de>
12 .\" Modified Mon Apr 22 01:50:54 1996 by Martin Schulze <joey@infodrom.north.de>
13 .\" 2001-07-25 added a clause about NULL proto (Martin Michlmayr or David N. Welton)
15 .TH getservent 3 (date) "Linux man-pages (unreleased)"
17 getservent, getservbyname, getservbyport, setservent, endservent \-
21 .RI ( libc ", " \-lc )
26 .B struct servent *getservent(void);
28 .BI "struct servent *getservbyname(const char *" name ", const char *" proto );
29 .BI "struct servent *getservbyport(int " port ", const char *" proto );
31 .BI "void setservent(int " stayopen );
32 .B void endservent(void);
37 function reads the next entry from the services database (see
42 the broken-out fields from the entry.
43 A connection is opened to the database if necessary.
50 for the entry from the database
51 that matches the service
57 is NULL, any protocol will be matched.
58 A connection is opened to the database if necessary.
65 for the entry from the database
68 (given in network byte order)
73 is NULL, any protocol will be matched.
74 A connection is opened to the database if necessary.
78 function opens a connection to the database,
79 and sets the next entry to the first entry.
83 then the connection to the database
84 will not be closed between calls to one of the
90 function closes the connection to the database.
94 structure is defined in
101 char *s_name; /* official service name */
102 char **s_aliases; /* alias list */
103 int s_port; /* port number */
104 char *s_proto; /* protocol to use */
114 The official name of the service.
117 A NULL-terminated list of alternative names for the service.
120 The port number for the service given in network byte order.
123 The name of the protocol to use with this service.
127 .BR getservbyname (),
130 functions return a pointer to a
133 structure, or NULL if an
134 error occurs or the end of the file is reached.
138 services database file
140 For an explanation of the terms used in this section, see
148 Interface Attribute Value
152 MT-Unsafe race:servent
153 race:serventbuf locale
158 MT-Unsafe race:servbyname
164 MT-Unsafe race:servbyport
171 MT-Unsafe race:servent
182 signifies that if any of the functions
187 are used in parallel in different threads of a program,
188 then data races could occur.
190 POSIX.1-2001, POSIX.1-2008, 4.3BSD.
194 .BR getservent_r (3),