📄 listen.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>listen</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4>NAME</h4><blockquote>listen - listen for socket connections and limit the queue of incoming connections</blockquote><h4>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="syssocket.h.html">sys/socket.h</a>>int listen(int <I>socket</I>, int <I>backlog</I>);</code></pre></blockquote><h4>DESCRIPTION</h4><blockquote>The<i>listen()</i>function marks a connection-mode socket, specified by the<I>socket</I>argument, as accepting connections, and limits the number of outstandingconnections in the socket's listen queue to the value specified by the<I>backlog</I>argument.<p>If<i>listen()</i>is called with a <I>backlog</I> argument value that is less than 0, thefunction sets the length of the socket's listen queue to 0.<p>The implementation may include incomplete connections in thequeue subject to the queue limit. The implementationmay also increase the specified queue limit internally if itincludes such incomplete connections in the queue subject tothis limit.<p>Implementations may limit the length of the socket's listen queue. If<I>backlog</I> exceeds the implementation-dependent maximum queue length, thelength of the socket's listen queue will be set to the maximum supportedvalue.<p>The socket in use may require the process to have appropriateprivileges to use the<i>listen()</i>function.</blockquote><h4>RETURN VALUE</h4><blockquote>Upon successful completions,<i>listen()</i>returns 0. Otherwise, -1is returned and <I>errno</I> is set to indicate the error.</blockquote><h4>ERRORS</h4><blockquote>The<i>listen()</i>function will fail if:<dl compact><dt>[EBADF]<dd>The <I>socket</I> argument is not a valid file descriptor.<dt>[EDESTADDRREQ]<dd>The socket is not bound to a local address, and the protocol does not supportlistening on an unbound socket.<dt>[EINVAL]<dd>The <I>socket</I> is already connected.<dt>[ENOTSOCK]<dd>The <I>socket</I> argument does not refer to a socket.<dt>[EOPNOTSUPP]<dd>The socket protocol does not support<i>listen()</i>.</dl><p>The<i>listen()</i>function may fail if:<dl compact><dt>[EACCES]<dd>The calling process does not have the appropriate privileges.<dt>[EINVAL]<dd>The <I>socket</I> has been shut down.<dt>[ENOBUFS]<dd>Insufficient resources are available in the system to complete the call.</dl></blockquote><h4>SEE ALSO</h4><blockquote><i><a href="accept.html">accept()</a></i>,<i><a href="connect.html">connect()</a></i>,<i><a href="socket.html">socket()</a></i>,<i><a href="syssocket.h.html"><sys/socket.h></a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -