mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
144 lines
6.3 KiB
HTML
144 lines
6.3 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 a message to a socket, whether it is connected or not</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.stream-socket-sendto" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">stream_socket_sendto</h1>
|
|
<p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">stream_socket_sendto</span> — <span class="dc-title">Sends a message to a socket, whether it is connected or not </span></p>
|
|
|
|
</div>
|
|
<div class="refsect1 description" id="refsect1-function.stream-socket-sendto-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>stream_socket_sendto</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">$data</code></span>
|
|
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>
|
|
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$address</code></span>
|
|
]] ) : <span class="type">int</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Sends the specified <code class="parameter">data</code> through the
|
|
<code class="parameter">socket</code>.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.stream-socket-sendto-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">socket</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The socket to send <code class="parameter">data</code> to.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">data</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The data to be sent.
|
|
</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:
|
|
<table class="doctable table">
|
|
<caption><strong>possible values for <code class="parameter">flags</code></strong></caption>
|
|
|
|
<tbody class="tbody">
|
|
<tr>
|
|
<td><strong><code>STREAM_OOB</code></strong></td>
|
|
<td>
|
|
Process OOB (out-of-band) data.
|
|
</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">address</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The address specified when the socket stream was created will be used
|
|
unless an alternate address is specified in <code class="parameter">address</code>.
|
|
</p>
|
|
<p class="para">
|
|
If specified, it must be in dotted quad (or [ipv6]) format.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.stream-socket-sendto-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns a result code, as an integer.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.stream-socket-sendto-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-4841">
|
|
<p><strong>Example #1 <span class="function"><strong>stream_socket_sendto()</strong></span> Example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/* Open a socket to port 1234 on localhost */<br /></span><span style="color: #0000BB">$socket </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_socket_client</span><span style="color: #007700">(</span><span style="color: #DD0000">'tcp://127.0.0.1:1234'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Send ordinary data via ordinary channels. */<br /></span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$socket</span><span style="color: #007700">, </span><span style="color: #DD0000">"Normal data transmit."</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Send more data out of band. */<br /></span><span style="color: #0000BB">stream_socket_sendto</span><span style="color: #007700">(</span><span style="color: #0000BB">$socket</span><span style="color: #007700">, </span><span style="color: #DD0000">"Out of Band data."</span><span style="color: #007700">, </span><span style="color: #0000BB">STREAM_OOB</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Close it up */<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$socket</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.stream-socket-sendto-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="stream_socket_recvfrom.html" class="function" rel="rdfs-seeAlso">stream_socket_recvfrom()</a> - Receives data from a socket, connected or not</span></li>
|
|
<li class="member"><span class="function"><a href="stream_socket_client.html" class="function" rel="rdfs-seeAlso">stream_socket_client()</a> - Open Internet or Unix domain socket connection</span></li>
|
|
<li class="member"><span class="function"><a href="stream_socket_server.html" class="function" rel="rdfs-seeAlso">stream_socket_server()</a> - Create an Internet or Unix domain server socket</span></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |