-
Notifications
You must be signed in to change notification settings - Fork 105
/
socket-accept.xml
112 lines (106 loc) · 3.74 KB
/
socket-accept.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 14dc7c47365f2b71f6c907a5ba5bccf42534d5a9 Maintainer: songmeifeng Status: ready -->
<refentry xml:id="function.socket-accept" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>socket_accept</refname>
<refpurpose>接受套接字上的连接</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>Socket</type><type>false</type></type><methodname>socket_accept</methodname>
<methodparam><type>Socket</type><parameter>socket</parameter></methodparam>
</methodsynopsis>
<para>
<parameter>socket</parameter> 是从 <function>socket_create</function> 创建,使用
<function>socket_bind</function> 绑定,<function>socket_listen</function> 监听的一个套接字实例。此函数接受在
<parameter>socket</parameter> 上创建的连接。当连接被成功创建后,返回一个可用于通信的
<classname>Socket</classname> 实例。若有多个连接排队,返回队头第一个连接。若没有待处理的连接,那么
<function>socket_accept</function> 默认阻塞,直到有一个连接出现。如果
<parameter>socket</parameter> 使用 <function>socket_set_blocking</function> 或
<function>socket_set_nonblock</function> 设置为非阻塞,那么
<function>socket_accept</function> 将直接返回 &false;。
</para>
<para>
<function>socket_accept</function> 返回的 <classname>Socket</classname> 实例不能用于接受新的连接。但
<parameter>socket</parameter> 依然保持打开状态,并且可以继续接受新的连接。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>socket</parameter></term>
<listitem>
<para>
使用 <function>socket_create</function> 创建的 <classname>Socket</classname> 实例。
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
成功时返回一个新的 <classname>Socket</classname> 实例,错误时返回 &false;。可以通过调用
<function>socket_last_error</function> 来检索实际的错误代码。将错误代码作为参数传递给
<function>socket_strerror</function> 以获得错误的文本解释。
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
成功时,该函数现在返回一个 <classname>Socket</classname> 实例;在此之前,返回值是一个 <type>resource</type>。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>socket_connect</function></member>
<member><function>socket_listen</function></member>
<member><function>socket_create</function></member>
<member><function>socket_bind</function></member>
<member><function>socket_strerror</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->