Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/endservent.html
2024-02-19 00:21:47 -05:00

143 lines
6.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>endservent</title>
</head>
<body bgcolor="white">
<basefont size="3"> <a name="endservent"></a> <a name="tag_03_122"></a><!-- endservent -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_122_01"></a>NAME</h4>
<blockquote>endservent, getservbyname, getservbyport, getservent, setservent - network services database functions</blockquote>
<h4><a name="tag_03_122_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><code><tt>#include &lt;<a href="../basedefs/netdb.h.html">netdb.h</a>&gt;<br>
<br>
void endservent(void);<br>
struct servent *getservbyname(const char *</tt><i>name</i><tt>, const char *</tt><i>proto</i><tt>);<br>
struct servent *getservbyport(int</tt> <i>port</i><tt>, const char *</tt><i>proto</i><tt>);<br>
struct servent *getservent(void);<br>
void setservent(int</tt> <i>stayopen</i><tt>);<br>
</tt></code></p>
</blockquote>
<h4><a name="tag_03_122_03"></a>DESCRIPTION</h4>
<blockquote>
<p>These functions shall retrieve information about network services. This information is considered to be stored in a database
that can be accessed sequentially or randomly. The implementation of this database is unspecified.</p>
<p>The <i>setservent</i>() function shall open a connection to the database, and set the next entry to the first entry. If the
<i>stayopen</i> argument is non-zero, the <i>net</i> database shall not be closed after each call to the <i>getservent</i>()
function (either directly, or indirectly through one of the other <a href="../functions/getservbyname.html"><i>getserv*</i>()</a>
functions), and the implementation may maintain an open file descriptor for the database.</p>
<p>The <i>getservent</i>() function shall read the next entry of the database, opening and closing a connection to the database as
necessary.</p>
<p>The <i>getservbyname</i>() function shall search the database from the beginning and find the first entry for which the service
name specified by <i>name</i> matches the <i>s_name</i> member and the protocol name specified by <i>proto</i> matches the
<i>s_proto</i> member, opening and closing a connection to the database as necessary. If <i>proto</i> is a null pointer, any value
of the <i>s_proto</i> member shall be matched.</p>
<p>The <i>getservbyport</i>() function shall search the database from the beginning and find the first entry for which the port
specified by <i>port</i> matches the <i>s_port</i> member and the protocol name specified by <i>proto</i> matches the
<i>s_proto</i> member, opening and closing a connection to the database as necessary. If <i>proto</i> is a null pointer, any value
of the <i>s_proto</i> member shall be matched. The <i>port</i> argument shall be in network byte order.</p>
<p>The <i>getservbyname</i>(), <i>getservbyport</i>(), and <i>getservent</i>() functions shall each return a pointer to a
<b>servent</b> structure, the members of which shall contain the fields of an entry in the network services database.</p>
<p>The <i>endservent</i>() function shall close the database, releasing any open file descriptor.</p>
<p>These functions need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe.</p>
</blockquote>
<h4><a name="tag_03_122_04"></a>RETURN VALUE</h4>
<blockquote>
<p>Upon successful completion, <i>getservbyname</i>(), <i>getservbyport</i>(), and <i>getservent</i>() return a pointer to a
<b>servent</b> structure if the requested entry was found, and a null pointer if the end of the database was reached or the
requested entry was not found. Otherwise, a null pointer is returned.</p>
</blockquote>
<h4><a name="tag_03_122_05"></a>ERRORS</h4>
<blockquote>
<p>No errors are defined.</p>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_122_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_122_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>The <i>port</i> argument of <i>getservbyport</i>() need not be compatible with the port values of all address families.</p>
<p>The <i>getservbyname</i>(), <i>getservbyport</i>(), and <i>getservent</i>() functions may return pointers to static data, which
may be overwritten by subsequent calls to any of these functions.</p>
</blockquote>
<h4><a name="tag_03_122_08"></a>RATIONALE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_122_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_122_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="endhostent.html"><i>endhostent</i>()</a> , <a href="endprotoent.html"><i>endprotoent</i>()</a> , <a href=
"htonl.html"><i>htonl</i>()</a> , <a href="inet_addr.html"><i>inet_addr</i>()</a> , the Base Definitions volume of
IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/netdb.h.html"><i>&lt;netdb.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_122_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 6. Derived from the XNS, Issue 5.2 specification.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>