<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.stream.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.stream-set-timeout.php',
    1 => 'stream_set_timeout',
    2 => 'Set timeout period on a stream',
  ),
  'up' => 
  array (
    0 => 'ref.stream.php',
    1 => 'Stream Функції',
  ),
  'prev' => 
  array (
    0 => 'function.stream-set-read-buffer.php',
    1 => 'stream_set_read_buffer',
  ),
  'next' => 
  array (
    0 => 'function.stream-set-write-buffer.php',
    1 => 'stream_set_write_buffer',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/stream/functions/stream-set-timeout.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stream-set-timeout" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_set_timeout</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stream_set_timeout</span> &mdash; <span class="dc-title">Set timeout period on a stream</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-set-timeout-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_set_timeout</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$stream</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$seconds</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$microseconds</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Sets the timeout value on <code class="parameter">stream</code>,
   expressed in the sum of <code class="parameter">seconds</code> and
   <code class="parameter">microseconds</code>. 
  </p>
  <p class="para">
   When the stream times out, the &#039;timed_out&#039; key of the array returned by
   <span class="function"><a href="function.stream-get-meta-data.php" class="function">stream_get_meta_data()</a></span> is set to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, although no
   error/warning is generated.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-set-timeout-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stream</code></dt>
     <dd>
      <p class="para">
       The target stream.
      </p>
     </dd>
    
    
     <dt><code class="parameter">seconds</code></dt>
     <dd>
      <p class="para">
       The seconds part of the timeout to be set.
      </p>
     </dd>
    
    
     <dt><code class="parameter">microseconds</code></dt>
     <dd>
      <p class="para">
       The microseconds part of the timeout to be set.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-set-timeout-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Повертає <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> у разі успіху або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.stream-set-timeout-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>stream_set_timeout()</strong></span> example</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">fsockopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"www.example.com"</span><span style="color: #007700">, </span><span style="color: #0000BB">80</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$fp</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"Unable to open\n"</span><span style="color: #007700">;<br />} else {<br /><br />    </span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">, </span><span style="color: #DD0000">"GET / HTTP/1.0\r\n\r\n"</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">stream_set_timeout</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$res </span><span style="color: #007700">= </span><span style="color: #0000BB">fread</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">, </span><span style="color: #0000BB">2000</span><span style="color: #007700">);<br /><br />    </span><span style="color: #0000BB">$info </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_get_meta_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /><br />    if (</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">'timed_out'</span><span style="color: #007700">]) {<br />        echo </span><span style="color: #DD0000">'Connection timed out!'</span><span style="color: #007700">;<br />    } else {<br />        echo </span><span style="color: #0000BB">$res</span><span style="color: #007700">;<br />    }<br /><br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 notes" id="refsect1-function.stream-set-timeout-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    This function doesn&#039;t work with advanced operations like
    <span class="function"><a href="function.stream-socket-recvfrom.php" class="function">stream_socket_recvfrom()</a></span>, use
    <span class="function"><a href="function.stream-select.php" class="function">stream_select()</a></span> with timeout parameter instead.
   </p>
  </p></blockquote>
  <p class="para">
   This function was previously called as
   <span class="function"><strong>set_socket_timeout()</strong></span> and later
   <span class="function"><a href="function.socket-set-timeout.php" class="function">socket_set_timeout()</a></span> but this usage is deprecated.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-set-timeout-seealso">
  <h3 class="title">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.fsockopen.php" class="function" rel="rdfs-seeAlso">fsockopen()</a> - Open Internet or Unix domain socket connection</span></li>
   <li><span class="function"><a href="function.fopen.php" class="function" rel="rdfs-seeAlso">fopen()</a> - Opens file or URL</span></li>
  </ul>
 </div>

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