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

>The manual says for fsockopen:
> Note: If you need to set a timeout for reading/writing data over the
> socket, use stream_set_timeout(), as the timeout parameter to
> fsockopen() only applies while connecting the socket.

That's still correct, there were no changes to this behavior.


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

[2007-03-07 20:00:16] andreas dot rieber at 2e-systems dot com

I want to use the default connection timeout for read/write but a
shorter timeout to connect (here 5 seconds). What happens is that the
first fgets gets also the 5 seconds timeout and so my header is empty.

The manual says for fsockopen:

 Note: If you need to set a timeout for reading/writing data over the
 socket, use stream_set_timeout(), as the timeout parameter to
 fsockopen() only applies while connecting the socket.

and thats absolut ok and what i want. It worked with php 5.2.0 and
before but not with 5.2.1.

------------------------------------------------------------------------

[2007-03-07 18:41:56] [EMAIL PROTECTED]

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


------------------------------------------------------------------------

[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