📄 function.socket-accept.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Accepts a connection on a socket</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.sockets.html">Socket Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-bind.html">socket_bind</a></div> <div class="up"><a href="ref.sockets.html">Socket Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.socket-accept" class="refentry"> <div class="refnamediv"> <h1 class="refname">socket_accept</h1> <p class="verinfo">(PHP 4 >= 4.0.7, PHP 5)</p><p class="refpurpose"><span class="refname">socket_accept</span> — <span class="dc-title">Accepts a connection on a socket</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><b><b>socket_accept</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$socket</tt></span> )</div> <p class="para rdfs-comment"> After the socket <i><tt class="parameter">socket</tt></i> has been created using <a href="function.socket-create.html" class="function">socket_create()</a>, bound to a name with <a href="function.socket-bind.html" class="function">socket_bind()</a>, and told to listen for connections with <a href="function.socket-listen.html" class="function">socket_listen()</a>, 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, <b>socket_accept()</b> will block until a connection becomes present. If <i><tt class="parameter">socket</tt></i> has been made non-blocking using <a href="function.socket-set-blocking.html" class="function">socket_set_blocking()</a> or <a href="function.socket-set-nonblock.html" class="function">socket_set_nonblock()</a>, <b><tt>FALSE</tt></b> will be returned. </p> <p class="para"> The socket resource returned by <b>socket_accept()</b> may not be used to accept new connections. The original listening socket <i><tt class="parameter">socket</tt></i>, however, remains open and may be reused. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">socket</tt></i></span> <dd> <p class="para"> A valid socket resource created with <a href="function.socket-create.html" class="function">socket_create()</a>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a new socket resource on success, or <b><tt>FALSE</tt></b> on error. The actual error code can be retrieved by calling <a href="function.socket-last-error.html" class="function">socket_last_error()</a>. This error code may be passed to <a href="function.socket-strerror.html" class="function">socket_strerror()</a> to get a textual explanation of the error. </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.socket-connect.html" class="function" rel="rdfs-seeAlso">socket_connect()</a></li> <li class="member"><a href="function.socket-listen.html" class="function" rel="rdfs-seeAlso">socket_listen()</a></li> <li class="member"><a href="function.socket-create.html" class="function" rel="rdfs-seeAlso">socket_create()</a></li> <li class="member"><a href="function.socket-bind.html" class="function" rel="rdfs-seeAlso">socket_bind()</a></li> <li class="member"><a href="function.socket-strerror.html" class="function" rel="rdfs-seeAlso">socket_strerror()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.sockets.html">Socket Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-bind.html">socket_bind</a></div> <div class="up"><a href="ref.sockets.html">Socket Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -