<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.sockets.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.socket-write.php',
    1 => 'socket_write',
    2 => 'Schreibt in einen Socket',
  ),
  'up' => 
  array (
    0 => 'ref.sockets.php',
    1 => 'Socket-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.socket-strerror.php',
    1 => 'socket_strerror',
  ),
  'next' => 
  array (
    0 => 'function.socket-wsaprotocol-info-export.php',
    1 => 'socket_wsaprotocol_info_export',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/sockets/functions/socket-write.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">socket_write</span> &mdash; <span class="dc-title">Schreibt in einen Socket</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.socket-write-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>socket_write</strong></span>(<span class="methodparam"><span class="type"><a href="class.socket.php" class="type Socket">Socket</a></span> <code class="parameter">$socket</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$length</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Die Funktion <span class="function"><strong>socket_write()</strong></span> schreibt aus dem Puffer
   <code class="parameter">data</code> in den Socket <code class="parameter">socket</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.socket-write-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">socket</code></dt>
     <dd>
      <p class="para">
      </p>
     </dd>
    
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       Der Puffer, dessen Inhalt geschrieben werden soll.
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       Mit dem optionalen Parameter <code class="parameter">length</code> kann man
       alternativ eine Anzahl von Bytes angeben, die in den Socket geschrieben
       werden sollen. Falls diese Anzahl größer ist, als
       <code class="parameter">data</code>, wird sie stillschweigend auf die Größe von
       <code class="parameter">data</code> gekürzt.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.socket-write-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt die Anzahl der erfolgreich in den Socket geschriebenen Bytes zurück.
   Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.. Der Fehlercode kann mit der Funktion
   <span class="function"><a href="function.socket-last-error.php" class="function">socket_last_error()</a></span> ermittelt werden. Dieser Fehlercode
   kann an die Funktion <span class="function"><a href="function.socket-strerror.php" class="function">socket_strerror()</a></span> übergeben werden,
   um eine textuelle Beschreibung des Fehlers zu erhalten.
  </p>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Es ist durchaus möglich, dass <span class="function"><strong>socket_write()</strong></span> den Wert 0
    zurckgibt, was bedeutet, dass kein einziges Byte geschrieben wurde.
    Vergewissern Sie sich, dass Sie den Operator <code class="literal">===</code>
    benutzen, um im Falle eines Fehlers auf <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zu testen.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.socket-write-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
  <td>8.0.0</td>
  <td>
   <code class="parameter">socket</code> ist nun eine
   <span class="classname"><a href="class.socket.php" class="classname">Socket</a></span>-Instanz; vorher war es eine
   <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
  </td>
 </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">length</code> ist nun ein Nullable-Typ.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 notes" id="refsect1-function.socket-write-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    <span class="function"><strong>socket_write()</strong></span> schreibt nicht notwendigerweise alle
    Bytes aus <code class="parameter">data</code>. Abhängig von den Puffern im Netzwerk
    usw. kann es sein, dass nur eine bestimmte Datenmenge, sogar nur ein Byte,
    geschrieben wird, obwohl <code class="parameter">data</code> größer ist.
    Um sicherzustellen, dass der Rest von <code class="parameter">data</code>
    übertragen wird, muss eine Schleife verwendet werden.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.socket-write-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.socket-accept.php" class="function" rel="rdfs-seeAlso">socket_accept()</a> - Akzeptiert eine Verbindung an einem Socket</span></li>
    <li><span class="function"><a href="function.socket-bind.php" class="function" rel="rdfs-seeAlso">socket_bind()</a> - Verkn&uuml;pft einen Socket mit einem Namen</span></li>
    <li><span class="function"><a href="function.socket-connect.php" class="function" rel="rdfs-seeAlso">socket_connect()</a> - Baut eine Verbindung &uuml;ber einen Socket auf</span></li>
    <li><span class="function"><a href="function.socket-listen.php" class="function" rel="rdfs-seeAlso">socket_listen()</a> - H&ouml;rt einen Socket nach Verbindungsanforderungen ab</span></li>
    <li><span class="function"><a href="function.socket-read.php" class="function" rel="rdfs-seeAlso">socket_read()</a> - Liest h&ouml;chstens die angegebene Anzahl Bytes von einem Socket</span></li>
    <li><span class="function"><a href="function.socket-strerror.php" class="function" rel="rdfs-seeAlso">socket_strerror()</a> - Gibt einen String zur&uuml;ck, der einen Socket-Fehler beschreibt</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>