1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" References consulted:
26 .\" Linux libc source code
27 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
29 .\" Modified Sat Jul 24 19:19:11 1993 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified Wed Oct 18 20:23:54 1995 by Martin Schulze <joey@infodrom.north.de>
31 .\" Modified Mon Apr 22 01:50:54 1996 by Martin Schulze <joey@infodrom.north.de>
32 .\" 2001-07-25 added a clause about NULL proto (Martin Michlmayr or David N. Welton)
34 .TH GETSERVENT 3 2021-03-22 "GNU" "Linux Programmer's Manual"
36 getservent, getservbyname, getservbyport, setservent, endservent \-
42 .B struct servent *getservent(void);
44 .BI "struct servent *getservbyname(const char *" name ", const char *" proto );
45 .BI "struct servent *getservbyport(int " port ", const char *" proto );
47 .BI "void setservent(int " stayopen );
48 .B void endservent(void);
53 function reads the next entry from the services database (see
58 the broken-out fields from the entry.
59 A connection is opened to the database if necessary.
66 for the entry from the database
67 that matches the service
73 is NULL, any protocol will be matched.
74 A connection is opened to the database if necessary.
81 for the entry from the database
84 (given in network byte order)
89 is NULL, any protocol will be matched.
90 A connection is opened to the database if necessary.
94 function opens a connection to the database,
95 and sets the next entry to the first entry.
99 then the connection to the database
100 will not be closed between calls to one of the
106 function closes the connection to the database.
110 structure is defined in
117 char *s_name; /* official service name */
118 char **s_aliases; /* alias list */
119 int s_port; /* port number */
120 char *s_proto; /* protocol to use */
130 The official name of the service.
133 A NULL-terminated list of alternative names for the service.
136 The port number for the service given in network byte order.
139 The name of the protocol to use with this service.
143 .BR getservbyname (),
146 functions return a pointer to a
149 structure, or NULL if an
150 error occurs or the end of the file is reached.
154 services database file
156 For an explanation of the terms used in this section, see
164 Interface Attribute Value
168 MT-Unsafe race:servent
169 race:serventbuf locale
174 MT-Unsafe race:servbyname
180 MT-Unsafe race:servbyport
187 MT-Unsafe race:servent
198 signifies that if any of the functions
203 are used in parallel in different threads of a program,
204 then data races could occur.
206 POSIX.1-2001, POSIX.1-2008, 4.3BSD.
210 .BR getservent_r (3),