1ENDSERVENT(3P) POSIX Programmer's Manual ENDSERVENT(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 endservent, getservbyname, getservbyport, getservent, setservent — net‐
13 work services database functions
14
16 #include <netdb.h>
17
18 void endservent(void);
19 struct servent *getservbyname(const char *name, const char *proto);
20 struct servent *getservbyport(int port, const char *proto);
21 struct servent *getservent(void);
22 void setservent(int stayopen);
23
25 These functions shall retrieve information about network services. This
26 information is considered to be stored in a database that can be
27 accessed sequentially or randomly. The implementation of this database
28 is unspecified.
29
30 The setservent() function shall open a connection to the database, and
31 set the next entry to the first entry. If the stayopen argument is non-
32 zero, the net database shall not be closed after each call to the get‐
33 servent() function (either directly, or indirectly through one of the
34 other getserv*() functions), and the implementation may maintain an
35 open file descriptor for the database.
36
37 The getservent() function shall read the next entry of the database,
38 opening and closing a connection to the database as necessary.
39
40 The getservbyname() function shall search the database from the begin‐
41 ning and find the first entry for which the service name specified by
42 name matches the s_name member and the protocol name specified by proto
43 matches the s_proto member, opening and closing a connection to the
44 database as necessary. If proto is a null pointer, any value of the
45 s_proto member shall be matched.
46
47 The getservbyport() function shall search the database from the begin‐
48 ning and find the first entry for which the port specified by port
49 matches the s_port member and the protocol name specified by proto
50 matches the s_proto member, opening and closing a connection to the
51 database as necessary. If proto is a null pointer, any value of the
52 s_proto member shall be matched. The port argument shall be a value
53 obtained by converting a uint16_t in network byte order to int.
54
55 The getservbyname(), getservbyport(), and getservent() functions shall
56 each return a pointer to a servent structure, the members of which
57 shall contain the fields of an entry in the network services database.
58
59 The endservent() function shall close the database, releasing any open
60 file descriptor.
61
62 These functions need not be thread-safe.
63
65 Upon successful completion, getservbyname(), getservbyport(), and get‐
66 servent() return a pointer to a servent structure if the requested
67 entry was found, and a null pointer if the end of the database was
68 reached or the requested entry was not found. Otherwise, a null
69 pointer is returned.
70
71 The application shall not modify the structure to which the return
72 value points, nor any storage areas pointed to by pointers within the
73 structure. The returned pointer, and pointers within the structure,
74 might be invalidated or the structure or the storage areas might be
75 overwritten by a subsequent call to getservbyname(), getservbyport(),
76 or getservent(). The returned pointer, and pointers within the struc‐
77 ture, might also be invalidated if the calling thread is terminated.
78
80 No errors are defined.
81
82 The following sections are informative.
83
85 None.
86
88 The port argument of getservbyport() need not be compatible with the
89 port values of all address families.
90
92 None.
93
95 None.
96
98 endhostent(), endprotoent(), htonl(), inet_addr()
99
100 The Base Definitions volume of POSIX.1‐2017, <netdb.h>
101
103 Portions of this text are reprinted and reproduced in electronic form
104 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
105 table Operating System Interface (POSIX), The Open Group Base Specifi‐
106 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
107 Electrical and Electronics Engineers, Inc and The Open Group. In the
108 event of any discrepancy between this version and the original IEEE and
109 The Open Group Standard, the original IEEE and The Open Group Standard
110 is the referee document. The original Standard can be obtained online
111 at http://www.opengroup.org/unix/online.html .
112
113 Any typographical or formatting errors that appear in this page are
114 most likely to have been introduced during the conversion of the source
115 files to man page format. To report such errors, see https://www.ker‐
116 nel.org/doc/man-pages/reporting_bugs.html .
117
118
119
120IEEE/The Open Group 2017 ENDSERVENT(3P)