<!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><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.socket-select.html">socket_select</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-sendmsg.html">socket_sendmsg</a></div> <div class="up"><a href="ref.sockets.html">Socket Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.socket-send" class="refentry"> <div class="refnamediv"> <h1 class="refname">socket_send</h1> <p class="verinfo">(PHP 4 >= 4.1.0, PHP 5)</p><p class="refpurpose"><span class="refname">socket_send</span> — <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">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <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> )</div> <p class="para rdfs-comment"> The function <span class="function"><strong>socket_send()</strong></span> sends <em><code class="parameter">len</code></em> bytes to the socket <em><code class="parameter">socket</code></em> from <em><code class="parameter">buf</code></em>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.socket-send-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">socket</code></em></span> <dd> <p class="para"> A valid socket resource created with <span class="function"><a href="function.socket-create.html" class="function">socket_create()</a></span> or <span class="function"><a href="function.socket-accept.html" class="function">socket_accept()</a></span>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">buf</code></em></span> <dd> <p class="para"> A buffer containing the data that will be sent to the remote host. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">len</code></em></span> <dd> <p class="para"> The number of bytes that will be sent to the remote host from <em><code class="parameter">buf</code></em>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">flags</code></em></span> <dd> <p class="para"> The value of <em><code class="parameter">flags</code></em> 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 <em><code class="parameter">flags</code></em></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> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.socket-send-returnvalues"> <h3 class="title">Return Values</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">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.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><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.socket-select.html">socket_select</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.socket-sendmsg.html">socket_sendmsg</a></div> <div class="up"><a href="ref.sockets.html">Socket Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>