uTools-Manuals/docs/php/socket_set_block.html
2019-04-28 19:00:34 +08:00

101 lines
4.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>Sets blocking mode on a socket resource</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.socket-set-block" class="refentry">
<div class="refnamediv">
<h1 class="refname">socket_set_block</h1>
<p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">socket_set_block</span> &mdash; <span class="dc-title">Sets blocking mode on a socket resource</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.socket-set-block-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>socket_set_block</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$socket</code></span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
The <span class="function"><strong>socket_set_block()</strong></span> function removes the
<strong><code>O_NONBLOCK</code></strong> flag on the socket specified by the
<code class="parameter">socket</code> parameter.
</p>
<p class="para">
When an operation (e.g. receive, send, connect, accept, ...) is performed on
a blocking socket, the script will pause its execution until it receives
a signal or it can perform the operation.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.socket-set-block-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>
or <span class="function"><a href="socket_accept.html" class="function">socket_accept()</a></span>.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.socket-set-block-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.socket-set-block-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-5606">
<p><strong>Example #1 <span class="function"><strong>socket_set_block()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$socket&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">socket_create_listen</span><span style="color: #007700">(</span><span style="color: #0000BB">1223</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">socket_set_block</span><span style="color: #007700">(</span><span style="color: #0000BB">$socket</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">socket_accept</span><span style="color: #007700">(</span><span style="color: #0000BB">$socket</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>
This example creates a listening socket on all interfaces on port 1223 and
sets the socket to <strong><code>O_BLOCK</code></strong> mode.
<span class="function"><a href="socket_accept.html" class="function">socket_accept()</a></span> will hang until there is a connection
to accept.
</p></div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.socket-set-block-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="socket_set_nonblock.html" class="function" rel="rdfs-seeAlso">socket_set_nonblock()</a> - Sets nonblocking mode for file descriptor fd</span></li>
<li class="member"><span class="function"><a href="socket_set_option.html" class="function" rel="rdfs-seeAlso">socket_set_option()</a> - Sets socket options for the socket</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>