<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.remote.other.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'book.sockets.php',
    1 => 'Socket',
    2 => 'Socket',
  ),
  'up' => 
  array (
    0 => 'refs.remote.other.php',
    1 => '其它服务',
  ),
  'prev' => 
  array (
    0 => 'class.snmpexception.php',
    1 => 'SNMPException',
  ),
  'next' => 
  array (
    0 => 'sockets.setup.php',
    1 => '安装/配置',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/sockets/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.sockets.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.sockets" class="book">
 
 <h1 class="title">Socket</h1>
 
 
 <div id="intro.sockets" class="preface">
  <h1 class="title">简介</h1>
  <p class="para">
   Socket 扩展是基于流行的 BSD sockets，实现了和 socket 通讯功能的底层接口，它可以和客户端一样当做一个 socket 服务器。
  </p>
  <p class="para">
   想了解更通用的客户端 socket 接口，请看
   <span class="function"><a href="function.stream-socket-client.php" class="function">stream_socket_client()</a></span>，
   <span class="function"><a href="function.stream-socket-server.php" class="function">stream_socket_server()</a></span>，
   <span class="function"><a href="function.fsockopen.php" class="function">fsockopen()</a></span> 和
   <span class="function"><a href="function.pfsockopen.php" class="function">pfsockopen()</a></span>。
  </p>
  <p class="para">
   使用这些函数时请注意，虽然他们中有很多和 C 函数同名的，但声明却很可能不同。未避免混淆，请仔细阅读函数描述。
  </p>
  <p class="para">
   不熟悉 socket 编程的可以在 Unix 手册上找到很多有用的信息，网上也有很多 C socket 编程方面的教程，简单修改一下就可以应用于 PHP socket
   编程。<a href="http://www.unixguide.net/network/socketfaq/" class="link external">&raquo;&nbsp;Unix Socket 常见问题</a> 是一个不错的入门资料。
  </p>
 </div>
 
 
 








 






 









 






 









 




 

 



 


<ul class="chunklist chunklist_book"><li><a href="sockets.setup.php">安装/配置</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="sockets.installation.php">安装</a></li><li><a href="sockets.resources.php">资源类型</a></li></ul></li><li><a href="sockets.constants.php">预定义常量</a></li><li><a href="sockets.examples.php">示例</a></li><li><a href="sockets.errors.php">Socket Errors</a></li><li><a href="ref.sockets.php">Socket 函数</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="function.socket-accept.php">socket_accept</a> — 接受套接字上的连接</li><li><a href="function.socket-addrinfo-bind.php">socket_addrinfo_bind</a> — 从给定的 addrinfo 创建并绑定一个套接字</li><li><a href="function.socket-addrinfo-connect.php">socket_addrinfo_connect</a> — 指定 addrinfo 创建并连接套接字</li><li><a href="function.socket-addrinfo-explain.php">socket_addrinfo_explain</a> — 获取有关 addrinfo 的信息</li><li><a href="function.socket-addrinfo-lookup.php">socket_addrinfo_lookup</a> — 获取数组，包含有关给定主机名的 getaddrinfo 内容</li><li><a href="function.socket-atmark.php">socket_atmark</a> — 确认 socket 是否处于带外数据标记</li><li><a href="function.socket-bind.php">socket_bind</a> — 给套接字绑定名字</li><li><a href="function.socket-clear-error.php">socket_clear_error</a> — 清除套接字或者最后的错误代码上的错误</li><li><a href="function.socket-close.php">socket_close</a> — 关闭 Socket 实例</li><li><a href="function.socket-cmsg-space.php">socket_cmsg_space</a> — Calculate message buffer size</li><li><a href="function.socket-connect.php">socket_connect</a> — 开启一个套接字连接</li><li><a href="function.socket-create.php">socket_create</a> — 创建一个套接字（通讯节点）</li><li><a href="function.socket-create-listen.php">socket_create_listen</a> — 在端口上打开一个套接字以接受连接</li><li><a href="function.socket-create-pair.php">socket_create_pair</a> — 创建一对彼此连接的套接字，并用数组存储</li><li><a href="function.socket-export-stream.php">socket_export_stream</a> — Export a socket into a stream that encapsulates a socket</li><li><a href="function.socket-get-option.php">socket_get_option</a> — 获取套接字的套接字选项</li><li><a href="function.socket-getopt.php">socket_getopt</a> — 别名 socket_get_option</li><li><a href="function.socket-getpeername.php">socket_getpeername</a> — 获取套接字远端名字</li><li><a href="function.socket-getsockname.php">socket_getsockname</a> — 获取套接字本地端的名字，返回主机名和端口号或是 Unix 文件系统路径，具体取决于套接字类型</li><li><a href="function.socket-import-stream.php">socket_import_stream</a> — 导入 stream</li><li><a href="function.socket-last-error.php">socket_last_error</a> — 返回套接字上的最后一个错误</li><li><a href="function.socket-listen.php">socket_listen</a> — 监听套接字的连接</li><li><a href="function.socket-read.php">socket_read</a> — 从套接字中读取最大长度的数据</li><li><a href="function.socket-recv.php">socket_recv</a> — 从已连接的 socket 接收数据</li><li><a href="function.socket-recvfrom.php">socket_recvfrom</a> — 从套接字接收数据，无论它是否是面向连接的</li><li><a href="function.socket-recvmsg.php">socket_recvmsg</a> — Read a message</li><li><a href="function.socket-select.php">socket_select</a> — 从给定套接字数组运行带指定超时时间的 select() 系统调用</li><li><a href="function.socket-send.php">socket_send</a> — 向已连接的套接字发送数据</li><li><a href="function.socket-sendmsg.php">socket_sendmsg</a> — Send a message</li><li><a href="function.socket-sendto.php">socket_sendto</a> — 向套接字发送消息，无论它是否已建立连接</li><li><a href="function.socket-set-block.php">socket_set_block</a> — 设置套接字为阻塞模式</li><li><a href="function.socket-set-nonblock.php">socket_set_nonblock</a> — 设置套接字为非阻塞模式</li><li><a href="function.socket-set-option.php">socket_set_option</a> — 为套接字设置套接字选项</li><li><a href="function.socket-setopt.php">socket_setopt</a> — 别名 socket_set_option</li><li><a href="function.socket-shutdown.php">socket_shutdown</a> — 关闭套接字接收或发送，或两者都关闭</li><li><a href="function.socket-strerror.php">socket_strerror</a> — 返回描述套接字错误的字符串</li><li><a href="function.socket-write.php">socket_write</a> — 向套接字写数据</li><li><a href="function.socket-wsaprotocol-info-export.php">socket_wsaprotocol_info_export</a> — 导出 WSAPROTOCOL_INFO 结构体</li><li><a href="function.socket-wsaprotocol-info-import.php">socket_wsaprotocol_info_import</a> — 从另一个进程导入套接字</li><li><a href="function.socket-wsaprotocol-info-release.php">socket_wsaprotocol_info_release</a> — 释放已导出的 WSAPROTOCOL_INFO 结构体</li></ul></li><li><a href="class.socket.php">Socket</a> — Socket 类</li><li><a href="class.addressinfo.php">AddressInfo</a> — AddressInfo 类</li></ul></div><?php manual_footer($setup); ?>