nlopess         Wed Feb  9 11:28:36 2005 EDT

  Modified files:              
    /phpdoc/en/reference/stream/functions       stream-set-timeout.xml 
  Log:
  fix #31897: expand description and improve example
  
http://cvs.php.net/diff.php/phpdoc/en/reference/stream/functions/stream-set-timeout.xml?r1=1.7&r2=1.8&ty=u
Index: phpdoc/en/reference/stream/functions/stream-set-timeout.xml
diff -u phpdoc/en/reference/stream/functions/stream-set-timeout.xml:1.7 
phpdoc/en/reference/stream/functions/stream-set-timeout.xml:1.8
--- phpdoc/en/reference/stream/functions/stream-set-timeout.xml:1.7     Wed Jun 
16 09:01:22 2004
+++ phpdoc/en/reference/stream/functions/stream-set-timeout.xml Wed Feb  9 
11:28:35 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
 <!-- splitted from ./en/functions/network.xml, last change in rev 1.18 -->
   <refentry id="function.stream-set-timeout">
    <refnamediv>
@@ -18,6 +18,13 @@
      Sets the timeout value on <parameter>stream</parameter>,
      expressed in the sum of <parameter>seconds</parameter> and
      <parameter>microseconds</parameter>. &return.success;
+    </para>
+    <para>
+     When the stream times out, the 'timed_out' key of the array returned by
+     <function>stream_get_meta_data</function> is set to &true;, although no
+     error/warning is generated.
+    </para>
+    <para>
      <example>
       <title><function>stream_set_timeout</function> example</title>
        <programlisting role="php">
@@ -27,12 +34,20 @@
 if (!$fp) {
     echo "Unable to open\n";
 } else {
-    fwrite($fp, "GET / HTTP/1.0\n\n");
+
+    fwrite($fp, "GET / HTTP/1.0\r\n\r\n");
     stream_set_timeout($fp, 2);
     $res = fread($fp, 2000);
-    var_dump(stream_get_meta_data($fp));
+
+    $info = stream_get_meta_data($fp);
     fclose($fp);
-    echo $res;
+
+    if ($info['timed_out']) {
+        echo 'Connection timed out!';
+    } else {
+        echo $res;
+    }
+
 }
 ?>
 ]]>

Reply via email to