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

152 lines
4.7 KiB
HTML

<!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>Sends data to a connected socket</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.socket-send" class="refentry">
<div class="refnamediv">
<h1 class="refname">socket_send</h1>
<p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">socket_send</span> &mdash; <span class="dc-title">Sends data to a connected socket</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.socket-send-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>socket_send</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$socket</code></span>
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$buf</code></span>
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$len</code></span>
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>
) : <span class="type">int</span></div>
<p class="para rdfs-comment">
The function <span class="function"><strong>socket_send()</strong></span> sends
<code class="parameter">len</code> bytes to the socket
<code class="parameter">socket</code> from <code class="parameter">buf</code>.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.socket-send-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>
<dt>
<code class="parameter">buf</code></dt>
<dd>
<p class="para">
A buffer containing the data that will be sent to the remote host.
</p>
</dd>
<dt>
<code class="parameter">len</code></dt>
<dd>
<p class="para">
The number of bytes that will be sent to the remote host from
<code class="parameter">buf</code>.
</p>
</dd>
<dt>
<code class="parameter">flags</code></dt>
<dd>
<p class="para">
The value of <code class="parameter">flags</code> can be any combination of
the following flags, joined with the binary OR (<em>|</em>)
operator.
<table class="doctable table">
<caption><strong>Possible values for <code class="parameter">flags</code></strong></caption>
<tbody class="tbody">
<tr>
<td><strong><code>MSG_OOB</code></strong></td>
<td>
Send OOB (out-of-band) data.
</td>
</tr>
<tr>
<td><strong><code>MSG_EOR</code></strong></td>
<td>
Indicate a record mark. The sent data completes the record.
</td>
</tr>
<tr>
<td><strong><code>MSG_EOF</code></strong></td>
<td>
Close the sender side of the socket and include an appropriate
notification of this at the end of the sent data. The sent data
completes the transaction.
</td>
</tr>
<tr>
<td><strong><code>MSG_DONTROUTE</code></strong></td>
<td>
Bypass routing, use direct interface.
</td>
</tr>
</tbody>
</table>
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.socket-send-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
<span class="function"><strong>socket_send()</strong></span> returns the number of bytes sent, or <strong><code>FALSE</code></strong> on error.
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.socket-send-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="socket_sendto.html" class="function" rel="rdfs-seeAlso">socket_sendto()</a> - Sends a message to a socket, whether it is connected or not</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>