Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5832

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Write to a socket</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.socket-strerror.html">socket_strerror</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="book.ssh2.html">SSH2</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-write" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">socket_write</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5)</p><p class="refpurpose"><span class="refname">socket_write</span> &mdash; <span class="dc-title">Write to a socket</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.socket-write-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>socket_write</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">$buffer</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$length</code><span class="initializer"> = 0</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   The function  <span class="function"><strong>socket_write()</strong></span> writes to the
   <em><code class="parameter">socket</code></em> from the given
   <em><code class="parameter">buffer</code></em>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.socket-write-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">
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">buffer</code></em></span>
     <dd>

      <p class="para">
       The buffer to be written.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">length</code></em></span>
     <dd>

      <p class="para">
       The optional parameter <em><code class="parameter">length</code></em> can specify an
       alternate length of bytes written to the socket. If this length is
       greater than the buffer length, it is silently truncated to the length
       of the buffer.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.socket-write-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the number of bytes successfully written to the socket or <strong><code>FALSE</code></strong> on failure.
   The error code can be retrieved with
    <span class="function"><a href="function.socket-last-error.html" class="function">socket_last_error()</a></span>. This code may be passed to
    <span class="function"><a href="function.socket-strerror.html" class="function">socket_strerror()</a></span> to get a textual explanation of the
   error.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    It is perfectly valid for  <span class="function"><strong>socket_write()</strong></span> to
    return zero which means no bytes have been written. Be sure to use the
    <em>===</em> operator to check for <strong><code>FALSE</code></strong> in case of an
    error.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 notes" id="refsect1-function.socket-write-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
     <span class="function"><strong>socket_write()</strong></span> does not necessarily write all bytes
    from the given buffer. It&#039;s valid that, depending on the network
    buffers etc., only a certain amount of data, even one byte, is written
    though your buffer is greater. You have to watch out so you don&#039;t
    unintentionally forget to transmit the rest of your data.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.socket-write-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.socket-accept.html" class="function" rel="rdfs-seeAlso">socket_accept()</a> - Accepts a connection on a socket</span></li>
    <li class="member"> <span class="function"><a href="function.socket-bind.html" class="function" rel="rdfs-seeAlso">socket_bind()</a> - Binds a name to a socket</span></li>
    <li class="member"> <span class="function"><a href="function.socket-connect.html" class="function" rel="rdfs-seeAlso">socket_connect()</a> - Initiates a connection on a socket</span></li>
    <li class="member"> <span class="function"><a href="function.socket-listen.html" class="function" rel="rdfs-seeAlso">socket_listen()</a> - Listens for a connection on a socket</span></li>
    <li class="member"> <span class="function"><a href="function.socket-read.html" class="function" rel="rdfs-seeAlso">socket_read()</a> - Reads a maximum of length bytes from a socket</span></li>
    <li class="member"> <span class="function"><a href="function.socket-strerror.html" class="function" rel="rdfs-seeAlso">socket_strerror()</a> - Return a string describing a socket error</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-strerror.html">socket_strerror</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="book.ssh2.html">SSH2</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>