uTools-Manuals/docs/php/socket_accept.html
2019-04-08 23:22:26 +08:00

96 lines
4.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Accepts a connection on a socket</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.socket-accept" class="refentry">
<div class="refnamediv">
<h1 class="refname">socket_accept</h1>
<p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">socket_accept</span> &mdash; <span class="dc-title">Accepts a connection on a socket</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.socket-accept-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>socket_accept</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$socket</code></span>
) : <span class="type">resource</span></div>
<p class="para rdfs-comment">
After the socket <code class="parameter">socket</code> has been created
using <span class="function"><a href="socket_create.html" class="function">socket_create()</a></span>, bound to a name with
<span class="function"><a href="socket_bind.html" class="function">socket_bind()</a></span>, and told to listen for connections
with <span class="function"><a href="socket_listen.html" class="function">socket_listen()</a></span>, this function will accept
incoming connections on that socket. Once a successful connection
is made, a new socket resource is returned, which may be used
for communication. If there are multiple connections queued on
the socket, the first will be used. If there are no pending
connections, <span class="function"><strong>socket_accept()</strong></span> will block until
a connection becomes present. If <code class="parameter">socket</code>
has been made non-blocking using
<span class="function"><a href="socket_set_blocking.html" class="function">socket_set_blocking()</a></span> or
<span class="function"><a href="socket_set_nonblock.html" class="function">socket_set_nonblock()</a></span>, <strong><code>FALSE</code></strong> will be returned.
</p>
<p class="para">
The socket resource returned by
<span class="function"><strong>socket_accept()</strong></span> may not be used to accept new
connections. The original listening socket
<code class="parameter">socket</code>, however, remains open and may be
reused.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.socket-accept-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">socket</code></dt>
<dd>
<p class="para">
A valid socket resource created with <span class="function"><a href="socket_create.html" class="function">socket_create()</a></span>.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.socket-accept-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
Returns a new socket resource on success, or <strong><code>FALSE</code></strong> on error. The actual
error code can be retrieved by calling
<span class="function"><a href="socket_last_error.html" class="function">socket_last_error()</a></span>. This error code may be passed to
<span class="function"><a href="socket_strerror.html" class="function">socket_strerror()</a></span> to get a textual explanation of the
error.
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.socket-accept-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="socket_connect.html" class="function" rel="rdfs-seeAlso">socket_connect()</a> - 开启一个套接字连接</span></li>
<li class="member"><span class="function"><a href="socket_listen.html" class="function" rel="rdfs-seeAlso">socket_listen()</a> - Listens for a connection on a socket</span></li>
<li class="member"><span class="function"><a href="socket_create.html" class="function" rel="rdfs-seeAlso">socket_create()</a> - 创建一个套接字(通讯节点)</span></li>
<li class="member"><span class="function"><a href="socket_bind.html" class="function" rel="rdfs-seeAlso">socket_bind()</a> - 给套接字绑定名字</span></li>
<li class="member"><span class="function"><a href="socket_strerror.html" class="function" rel="rdfs-seeAlso">socket_strerror()</a> - Return a string describing a socket error</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>