⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listen.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 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-2003 The Open Group, All Rights Reserved --><title>listen</title></head><body bgcolor="white"><basefont size="3"> <a name="listen"></a> <a name="tag_03_335"></a><!-- listen --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_335_01"></a>NAME</h4><blockquote>listen - listen for socket connections and limit the queue of incoming connections</blockquote><h4><a name="tag_03_335_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/sys/socket.h.html">sys/socket.h</a>&gt;<br><br> int listen(int</tt> <i>socket</i><tt>, int</tt> <i>backlog</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_335_03"></a>DESCRIPTION</h4><blockquote><p>The <i>listen</i>() function shall mark a connection-mode socket, specified by the <i>socket</i> argument, as acceptingconnections.</p><p>The <i>backlog</i> argument provides a hint to the implementation which the implementation shall use to limit the number ofoutstanding connections in the socket's listen queue. Implementations may impose a limit on <i>backlog</i> and silently reduce thespecified value. Normally, a larger <i>backlog</i> argument value shall result in a larger or equal length of the listen queue.Implementations shall support values of <i>backlog</i> up to SOMAXCONN, defined in <a href="../basedefs/sys/socket.h.html"><i>&lt;sys/socket.h&gt;</i></a>.</p><p>The implementation may include incomplete connections in its listen queue. The limits on the number of incomplete connectionsand completed connections queued may be different.</p><p>The implementation may have an upper limit on the length of the listen queue-either global or per accepting socket. If<i>backlog</i> exceeds this limit, the length of the listen queue is set to the limit.</p><p>If <i>listen</i>() is called with a <i>backlog</i> argument value that is less than 0, the function behaves as if it had beencalled with a <i>backlog</i> argument value of 0.</p><p>A <i>backlog</i> argument of 0 may allow the socket to accept connections, in which case the length of the listen queue may beset to an implementation-defined minimum value.</p><p>The socket in use may require the process to have appropriate privileges to use the <i>listen</i>() function.</p></blockquote><h4><a name="tag_03_335_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completions, <i>listen</i>() shall return 0; otherwise, -1 shall be returned and <i>errno</i> set to indicatethe error.</p></blockquote><h4><a name="tag_03_335_05"></a>ERRORS</h4><blockquote><p>The <i>listen</i>() function shall fail if:</p><dl compact><dt>[EBADF]</dt><dd>The <i>socket</i> argument is not a valid file descriptor.</dd><dt>[EDESTADDRREQ]</dt><dd><br>The socket is not bound to a local address, and the protocol does not support listening on an unbound socket.</dd><dt>[EINVAL]</dt><dd>The <i>socket</i> is already connected.</dd><dt>[ENOTSOCK]</dt><dd>The <i>socket</i> argument does not refer to a socket.</dd><dt>[EOPNOTSUPP]</dt><dd>The socket protocol does not support <i>listen</i>().</dd></dl><p>The <i>listen</i>() function may fail if:</p><dl compact><dt>[EACCES]</dt><dd>The calling process does not have the appropriate privileges.</dd><dt>[EINVAL]</dt><dd>The <i>socket</i> has been shut down.</dd><dt>[ENOBUFS]</dt><dd>Insufficient resources are available in the system to complete the call.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_335_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_335_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_335_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_335_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_335_10"></a>SEE ALSO</h4><blockquote><p><a href="accept.html"><i>accept</i>()</a> , <a href="connect.html"><i>connect</i>()</a> , <a href="socket.html"><i>socket</i>()</a> , the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/sys/socket.h.html"><i>&lt;sys/socket.h&gt;</i></a></p></blockquote><h4><a name="tag_03_335_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 6. Derived from the XNS, Issue 5.2 specification.</p><p>The DESCRIPTION is updated to describe the relationship of SOMAXCONN and the <i>backlog</i> argument.</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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -