1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "ENDSERVENT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
5 endservent, getservbyname, getservbyport, getservent, setservent \-
6 network services database functions
12 void endservent(void);
14 struct servent *getservbyname(const char *\fP\fIname\fP\fB, const
15 char *\fP\fIproto\fP\fB);
17 struct servent *getservbyport(int\fP \fIport\fP\fB, const char *\fP\fIproto\fP\fB);
19 struct servent *getservent(void);
21 void setservent(int\fP \fIstayopen\fP\fB);
26 These functions shall retrieve information about network services.
27 This information is considered to be stored in a database
28 that can be accessed sequentially or randomly. The implementation
29 of this database is unspecified.
31 The \fIsetservent\fP() function shall open a connection to the database,
32 and set the next entry to the first entry. If the
33 \fIstayopen\fP argument is non-zero, the \fInet\fP database shall
34 not be closed after each call to the \fIgetservent\fP()
35 function (either directly, or indirectly through one of the other
37 functions), and the implementation may maintain an open file descriptor
40 The \fIgetservent\fP() function shall read the next entry of the database,
41 opening and closing a connection to the database as
44 The \fIgetservbyname\fP() function shall search the database from
45 the beginning and find the first entry for which the service
46 name specified by \fIname\fP matches the \fIs_name\fP member and the
47 protocol name specified by \fIproto\fP matches the
48 \fIs_proto\fP member, opening and closing a connection to the database
49 as necessary. If \fIproto\fP is a null pointer, any value
50 of the \fIs_proto\fP member shall be matched.
52 The \fIgetservbyport\fP() function shall search the database from
53 the beginning and find the first entry for which the port
54 specified by \fIport\fP matches the \fIs_port\fP member and the protocol
55 name specified by \fIproto\fP matches the
56 \fIs_proto\fP member, opening and closing a connection to the database
57 as necessary. If \fIproto\fP is a null pointer, any value
58 of the \fIs_proto\fP member shall be matched. The \fIport\fP argument
59 shall be in network byte order.
61 The \fIgetservbyname\fP(), \fIgetservbyport\fP(), and \fIgetservent\fP()
62 functions shall each return a pointer to a
63 \fBservent\fP structure, the members of which shall contain the fields
64 of an entry in the network services database.
66 The \fIendservent\fP() function shall close the database, releasing
67 any open file descriptor.
69 These functions need not be reentrant. A function that is not required
70 to be reentrant is not required to be thread-safe.
73 Upon successful completion, \fIgetservbyname\fP(), \fIgetservbyport\fP(),
74 and \fIgetservent\fP() return a pointer to a
75 \fBservent\fP structure if the requested entry was found, and a null
76 pointer if the end of the database was reached or the
77 requested entry was not found. Otherwise, a null pointer is returned.
80 No errors are defined.
82 \fIThe following sections are informative.\fP
88 The \fIport\fP argument of \fIgetservbyport\fP() need not be compatible
89 with the port values of all address families.
91 The \fIgetservbyname\fP(), \fIgetservbyport\fP(), and \fIgetservent\fP()
92 functions may return pointers to static data, which
93 may be overwritten by subsequent calls to any of these functions.
102 \fIendhostent\fP() , \fIendprotoent\fP() , \fIhtonl\fP() , \fIinet_addr\fP()
103 , the Base Definitions volume of
104 IEEE\ Std\ 1003.1-2001, \fI<netdb.h>\fP
106 Portions of this text are reprinted and reproduced in electronic form
107 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
108 -- Portable Operating System Interface (POSIX), The Open Group Base
109 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
110 Electrical and Electronics Engineers, Inc and The Open Group. In the
111 event of any discrepancy between this version and the original IEEE and
112 The Open Group Standard, the original IEEE and The Open Group Standard
113 is the referee document. The original Standard can be obtained online at
114 http://www.opengroup.org/unix/online.html .