From: andreas dot rieber at 2e-systems dot com Operating system: OpenSuse PHP version: 5.2.1 PHP Bug Type: Network related Bug description: fsockopen timeout parameter overwrites timeout for reading
Description: ------------ The timeout parameter of fsockopen overwrites the general read/write timeout. Without the timeout parameter in fsockopen or if you use stream_set_timeout after fsockopen it works. I created scipt a.php which opens b.php. the connection has a timeout of 5 seconds. b.php sleeps for 7 seconds. The first fgets fails and stream_get_meta_data shows that it timed out. It works with php 5.2.0. Reproduce code: --------------- code a.php <?php $fp = @fsockopen( 'localhost', 80, &$errno, &$errstr, 5); if( !$fp) die( "$errno: $errstr"); fwrite( $fp, "GET /b.php HTTP/1.0\r\nHost: localhost\r\n\r\n"); // read result $data = ''; while( !feof( $fp)) { $line = fgets( $fp, 8192); if( trim( $line) == '') break; $data .= $line; } fclose( $fp); // check header if( eregi( '^HTTP\/[0-9\.]+ ([0-9]{3}) .*', $data, $reg)) { echo "Header OK"; } else { echo "Header failed"; } ?> code b.php <?php sleep( 7); ?> Expected result: ---------------- Header OK Actual result: -------------- Header failed -- Edit bug report at http://bugs.php.net/?id=40750&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40750&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40750&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40750&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40750&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40750&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40750&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40750&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40750&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40750&r=support Expected behavior: http://bugs.php.net/fix.php?id=40750&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40750&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40750&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40750&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40750&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40750&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40750&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40750&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40750&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40750&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40750&r=mysqlcfg