ID:               40750
 Updated by:       [EMAIL PROTECTED]
 Reported By:      andreas dot rieber at 2e-systems dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Network related
 Operating System: OpenSuse
 PHP Version:      5.2.1
 New Comment:

I get "Header OK".
Also I don't understand what the expected result has to do with the
timeout.



Previous Comments:
------------------------------------------------------------------------

[2007-03-07 18:29:03] andreas dot rieber at 2e-systems dot com

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 this bug report at http://bugs.php.net/?id=40750&edit=1

Reply via email to