svn: /phpdoc/en/trunk/reference/filesystem/functions/ feof.xml

From: Date: Sun, 10 Jan 2010 23:38:48 +0000
Subject: svn: /phpdoc/en/trunk/reference/filesystem/functions/ feof.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-5806@lists.php.net to get a copy of this message
kalle Sun, 10 Jan 2010 23:38:48 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=293364 Log: Fixed bug #43782 (feof() does not detect timeout on socket) Bug: http://bugs.php.net/43782 (Open) feof() does not detect timeout on socket Changed paths: U phpdoc/en/trunk/reference/filesystem/functions/feof.xml Modified: phpdoc/en/trunk/reference/filesystem/functions/feof.xml =================================================================== --- phpdoc/en/trunk/reference/filesystem/functions/feof.xml 2010-01-10 23:16:29 UTC (rev 293363) +++ phpdoc/en/trunk/reference/filesystem/functions/feof.xml 2010-01-10 23:38:48 UTC (rev 293364) @@ -44,10 +44,32 @@ <warning> <simpara> If a connection opened by <function>fsockopen</function> wasn't closed - by the server, <function>feof</function> will wait until a timeout has - been reached to return &true;. The default timeout value is 60 seconds. - You may use <function>stream_set_timeout</function> to change this - value. + by the server, <function>feof</function> will hang. To workaround this, see + below example: + <example> + <title>Handling timeouts with <function>feof</function></title> + <programlisting role="php"> + <![CDATA[ +<?php +function safe_feof($fp, &start = NULL) { + $start = microtime(true); + + return feof($fp); +} + +/* Assuming $fp is previously opened by fsockopen() */ + +$start = NULL; +$timeout = ini_get('default_socket_timeout'); + +while(!safe_feof($fp, $start) && (microtime(true) - $start) < $timeout) +{ + /* Handle */ +} +?> +]]> + </programlisting> + </example> </simpara> </warning> <warning>

« previous php.doc.cvs (#5806) next »