1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
25 TITLE="getrrsetbyname"
26 HREF="net-common-tcpip-manpages-getrrsetbyname.html"><LINK
28 TITLE="if_nametoindex"
29 HREF="net-common-tcpip-manpages-if-nametoindex.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="net-common-tcpip-manpages-getrrsetbyname.html"
65 >Chapter 38. TCP/IP Library Reference</TD
71 HREF="net-common-tcpip-manpages-if-nametoindex.html"
85 NAME="NET-COMMON-TCPIP-MANPAGES-GETSERVENT">getservent</H1
94 >GETSERVENT(3) System Library Functions Manual GETSERVENT(3)
97 getservent, getservbyport, getservbyname, setservent, endservent - get
101 #include <netdb.h>
107 getservbyname(char *name, char *proto);
110 getservbyport(int port, char *proto);
113 setservent(int stayopen);
119 The getservent(), getservbyname(), and getservbyport() functions each
120 return a pointer to an object with the following structure containing the
121 broken-out fields of a line in the network services database,
125 char *s_name; /* official name of service */
126 char **s_aliases; /* alias list */
127 int s_port; /* port service resides at */
128 char *s_proto; /* protocol to use */
131 The members of this structure are:
133 s_name The official name of the service.
135 s_aliases A zero-terminated list of alternate names for the service.
137 s_port The port number at which the service resides. Port numbers
138 are returned in network byte order.
140 s_proto The name of the protocol to use when contacting the service.
142 The getservent() function reads the next line of the file, opening the
145 The setservent() function opens and rewinds the file. If the stayopen
146 flag is non-zero, the net database will not be closed after each call to
147 getservbyname() or getservbyport().
149 The endservent() function closes the file.
151 The getservbyname() and getservbyport() functions sequentially search
152 from the beginning of the file until a matching protocol name or port
153 number (specified in network byte order) is found, or until EOF is
154 encountered. If a protocol name is also supplied (non-null), searches
155 must also match the protocol.
161 Null pointer (0) returned on EOF or error.
164 getprotoent(3), services(5)
167 The getservent(), getservbyport(), getservbyname(), setservent(), and
168 endservent() functions appeared in 4.2BSD.
171 These functions use static data storage; if the data is needed for future
172 use, it should be copied before any subsequent calls overwrite it.
173 Expecting port numbers to fit in a 32-bit quantity is probably naive.
175 BSD January 12, 1994 BSD
186 SUMMARY="Footer navigation table"
197 HREF="net-common-tcpip-manpages-getrrsetbyname.html"
215 HREF="net-common-tcpip-manpages-if-nametoindex.html"
231 HREF="tcpip-library-reference.html"