add directory Ref-docs
This commit is contained in:
211
Ref-docs/POSIX/susv3/functions/accept.html
Normal file
211
Ref-docs/POSIX/susv3/functions/accept.html
Normal file
@@ -0,0 +1,211 @@
|
||||
<!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>accept</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
||||
</script>
|
||||
|
||||
<basefont size="3"> <a name="accept"></a> <a name="tag_03_09"></a><!-- accept -->
|
||||
<!--header start-->
|
||||
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
||||
IEEE Std 1003.1-2001<br>
|
||||
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
||||
|
||||
<!--header end-->
|
||||
<hr size="2" noshade>
|
||||
<h4><a name="tag_03_09_01"></a>NAME</h4>
|
||||
|
||||
<blockquote>accept - accept a new connection on a socket</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_02"></a>SYNOPSIS</h4>
|
||||
|
||||
<blockquote class="synopsis">
|
||||
<p><code><tt>#include <<a href="../basedefs/sys/socket.h.html">sys/socket.h</a>><br>
|
||||
<br>
|
||||
int accept(int</tt> <i>socket</i><tt>, struct sockaddr *restrict</tt> <i>address</i><tt>,<br>
|
||||
socklen_t *restrict</tt> <i>address_len</i><tt>);<br>
|
||||
</tt></code></p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_03"></a>DESCRIPTION</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>accept</i>() function shall extract the first connection on the queue of pending connections, create a new socket with
|
||||
the same socket type protocol and address family as the specified socket, and allocate a new file descriptor for that socket.</p>
|
||||
|
||||
<p>The <i>accept</i>() function takes the following arguments:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt><i>socket</i></dt>
|
||||
|
||||
<dd>Specifies a socket that was created with <a href="../functions/socket.html"><i>socket</i>()</a>, has been bound to an address
|
||||
with <a href="../functions/bind.html"><i>bind</i>()</a>, and has issued a successful call to <a href=
|
||||
"../functions/listen.html"><i>listen</i>()</a>.</dd>
|
||||
|
||||
<dt><i>address</i></dt>
|
||||
|
||||
<dd>Either a null pointer, or a pointer to a <b>sockaddr</b> structure where the address of the connecting socket shall be
|
||||
returned.</dd>
|
||||
|
||||
<dt><i>address_len</i></dt>
|
||||
|
||||
<dd>Points to a <b>socklen_t</b> structure which on input specifies the length of the supplied <b>sockaddr</b> structure, and on
|
||||
output specifies the length of the stored address.</dd>
|
||||
</dl>
|
||||
|
||||
<p>If <i>address</i> is not a null pointer, the address of the peer for the accepted connection shall be stored in the
|
||||
<b>sockaddr</b> structure pointed to by <i>address</i>, and the length of this address shall be stored in the object pointed to by
|
||||
<i>address_len</i>.</p>
|
||||
|
||||
<p>If the actual length of the address is greater than the length of the supplied <b>sockaddr</b> structure, the stored address
|
||||
shall be truncated.</p>
|
||||
|
||||
<p>If the protocol permits connections by unbound clients, and the peer is not bound, then the value stored in the object pointed
|
||||
to by <i>address</i> is unspecified.</p>
|
||||
|
||||
<p>If the listen queue is empty of connection requests and O_NONBLOCK is not set on the file descriptor for the socket,
|
||||
<i>accept</i>() shall block until a connection is present. If the <a href="../functions/listen.html"><i>listen</i>()</a> queue is
|
||||
empty of connection requests and O_NONBLOCK is set on the file descriptor for the socket, <i>accept</i>() shall fail and set
|
||||
<i>errno</i> to [EAGAIN] or [EWOULDBLOCK].</p>
|
||||
|
||||
<p>The accepted socket cannot itself accept more connections. The original socket remains open and can accept more connections.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_04"></a>RETURN VALUE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>Upon successful completion, <i>accept</i>() shall return the non-negative file descriptor of the accepted socket. Otherwise, -1
|
||||
shall be returned and <i>errno</i> set to indicate the error.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_05"></a>ERRORS</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>The <i>accept</i>() function shall fail if:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt>[EAGAIN] or [EWOULDBLOCK]</dt>
|
||||
|
||||
<dd><br>
|
||||
O_NONBLOCK is set for the socket file descriptor and no connections are present to be accepted.</dd>
|
||||
|
||||
<dt>[EBADF]</dt>
|
||||
|
||||
<dd>The <i>socket</i> argument is not a valid file descriptor.</dd>
|
||||
|
||||
<dt>[ECONNABORTED]</dt>
|
||||
|
||||
<dd><br>
|
||||
A connection has been aborted.</dd>
|
||||
|
||||
<dt>[EINTR]</dt>
|
||||
|
||||
<dd>The <i>accept</i>() function was interrupted by a signal that was caught before a valid connection arrived.</dd>
|
||||
|
||||
<dt>[EINVAL]</dt>
|
||||
|
||||
<dd>The <i>socket</i> is not accepting connections.</dd>
|
||||
|
||||
<dt>[EMFILE]</dt>
|
||||
|
||||
<dd>{OPEN_MAX} file descriptors are currently open in the calling process.</dd>
|
||||
|
||||
<dt>[ENFILE]</dt>
|
||||
|
||||
<dd>The maximum number of file descriptors in the system are already open.</dd>
|
||||
|
||||
<dt>[ENOTSOCK]</dt>
|
||||
|
||||
<dd>The <i>socket</i> argument does not refer to a socket.</dd>
|
||||
|
||||
<dt>[EOPNOTSUPP]</dt>
|
||||
|
||||
<dd>The socket type of the specified socket does not support accepting connections.</dd>
|
||||
</dl>
|
||||
|
||||
<p>The <i>accept</i>() function may fail if:</p>
|
||||
|
||||
<dl compact>
|
||||
<dt>[ENOBUFS]</dt>
|
||||
|
||||
<dd>No buffer space is available.</dd>
|
||||
|
||||
<dt>[ENOMEM]</dt>
|
||||
|
||||
<dd>There was insufficient memory available to complete the operation.</dd>
|
||||
|
||||
<dt>[EPROTO]</dt>
|
||||
|
||||
<dd><sup>[<a href="javascript:open_code('XSR')">XSR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
||||
A protocol error has occurred; for example, the STREAMS protocol stack has not been initialized. <img src="../images/opt-end.gif"
|
||||
alt="[Option End]" border="0"></dd>
|
||||
</dl>
|
||||
</blockquote>
|
||||
|
||||
<hr>
|
||||
<div class="box"><em>The following sections are informative.</em></div>
|
||||
|
||||
<h4><a name="tag_03_09_06"></a>EXAMPLES</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_07"></a>APPLICATION USAGE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>When a connection is available, <a href="../functions/select.html"><i>select</i>()</a> indicates that the file descriptor for
|
||||
the socket is ready for reading.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_08"></a>RATIONALE</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_09"></a>FUTURE DIRECTIONS</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>None.</p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_10"></a>SEE ALSO</h4>
|
||||
|
||||
<blockquote>
|
||||
<p><a href="bind.html"><i>bind</i>()</a> , <a href="connect.html"><i>connect</i>()</a> , <a href="listen.html"><i>listen</i>()</a>
|
||||
, <a href="socket.html"><i>socket</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
||||
"../basedefs/sys/socket.h.html"><i><sys/socket.h></i></a></p>
|
||||
</blockquote>
|
||||
|
||||
<h4><a name="tag_03_09_11"></a>CHANGE HISTORY</h4>
|
||||
|
||||
<blockquote>
|
||||
<p>First released in Issue 6. Derived from the XNS, Issue 5.2 specification.</p>
|
||||
|
||||
<p>The <b>restrict</b> keyword is added to the <i>accept</i>() prototype for alignment with the ISO/IEC 9899:1999
|
||||
standard.</p>
|
||||
</blockquote>
|
||||
|
||||
<div class="box"><em>End of informative text.</em></div>
|
||||
|
||||
<hr>
|
||||
<hr size="2" noshade>
|
||||
<center><font size="2"><!--footer start-->
|
||||
UNIX ® is a registered Trademark of The Open Group.<br>
|
||||
POSIX ® 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>
|
||||
|
||||
Reference in New Issue
Block a user