<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.stream.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.stream-socket-accept.php',
    1 => 'stream_socket_accept',
    2 => '接受由 stream_socket_server 创建的套接字连接',
  ),
  'up' => 
  array (
    0 => 'ref.stream.php',
    1 => 'Stream 函数',
  ),
  'prev' => 
  array (
    0 => 'function.stream-set-write-buffer.php',
    1 => 'stream_set_write_buffer',
  ),
  'next' => 
  array (
    0 => 'function.stream-socket-client.php',
    1 => 'stream_socket_client',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/stream/functions/stream-socket-accept.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stream-socket-accept" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_socket_accept</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stream_socket_accept</span> &mdash; <span class="dc-title">接受由 <span class="function"><a href="function.stream-socket-server.php" class="function">stream_socket_server()</a></span> 创建的套接字连接</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.stream-socket-accept-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_socket_accept</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$socket</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.float.php" class="type float">float</a></span></span> <code class="parameter">$timeout</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter reference">&$peer_name</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   接受由 <span class="function"><a href="function.stream-socket-server.php" class="function">stream_socket_server()</a></span> 创建的套接字连接。
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.stream-socket-accept-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">socket</code></dt>
     <dd>
      <p class="para">
       需要接受的服务器创建的套接字连接。
      </p>
     </dd>
    
    
     <dt><code class="parameter">timeout</code></dt>
     <dd>
      <p class="para">
       覆盖默认的套接字接受的超时时限。输入的时间需以秒为单位。默认情况下，使用
       <a href="filesystem.configuration.php#ini.default-socket-timeout" class="link">default_socket_timeout</a>
       作为超时时限。
      </p>
     </dd>
    
    
     <dt><code class="parameter">peer_name</code></dt>
     <dd>
      <p class="para">
       如果已选的传输器存在且有效的已连接客户端，则将该值设置为已连接客户端名称（地址）。
      </p>
      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <p class="para">
        也可以之后通过 <span class="function"><a href="function.stream-socket-get-name.php" class="function">stream_socket_get_name()</a></span> 来确定。
       </p>
      </p></blockquote>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-socket-accept-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回接受套接之后的资源流  或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.stream-socket-accept-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       现在 <code class="parameter">timeout</code> 可以为 null。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 notes" id="refsect1-function.stream-socket-accept-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    该函数不能被用于 UDP 套接字。可以使用 <span class="function"><a href="function.stream-socket-recvfrom.php" class="function">stream_socket_recvfrom()</a></span> 和
    <span class="function"><a href="function.stream-socket-sendto.php" class="function">stream_socket_sendto()</a></span> 来取而代之。
   </p>
 </div>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.stream-socket-accept-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.stream-socket-server.php" class="function" rel="rdfs-seeAlso">stream_socket_server()</a> - 创建 Internet 或 Unix 域服务器套接字</span></li>
    <li><span class="function"><a href="function.stream-socket-get-name.php" class="function" rel="rdfs-seeAlso">stream_socket_get_name()</a> - 获取本地或者远程的套接字名称</span></li>
    <li><span class="function"><a href="function.stream-set-blocking.php" class="function" rel="rdfs-seeAlso">stream_set_blocking()</a> - 为资源流设置阻塞或者阻塞模式</span></li>
    <li><span class="function"><a href="function.stream-set-timeout.php" class="function" rel="rdfs-seeAlso">stream_set_timeout()</a> - Set timeout period on a stream</span></li>
    <li><span class="function"><a href="function.fgets.php" class="function" rel="rdfs-seeAlso">fgets()</a> - 从文件指针中读取一行</span></li>
    <li><span class="function"><a href="function.fgetss.php" class="function" rel="rdfs-seeAlso">fgetss()</a> - 从文件指针中读取一行并过滤掉 HTML 标记</span></li>
    <li><span class="function"><a href="function.fwrite.php" class="function" rel="rdfs-seeAlso">fwrite()</a> - 写入文件（可安全用于二进制文件）</span></li>
    <li><span class="function"><a href="function.fclose.php" class="function" rel="rdfs-seeAlso">fclose()</a> - 关闭一个已打开的文件指针</span></li>
    <li><span class="function"><a href="function.feof.php" class="function" rel="rdfs-seeAlso">feof()</a> - 测试文件指针是否到了文件结束的位置</span></li>
    <li><a href="ref.curl.php" class="xref">cURL 函数</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>