ID:               33471
 Updated by:       [EMAIL PROTECTED]
 Reported By:      info at goldenelite dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Sockets related
 Operating System: FreeBSD 4.10
 PHP Version:      5.0.4
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip




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

[2005-06-25 07:36:17] info at goldenelite dot com

Description:
------------
The socker_read function has two modes: PHP_BINARY_READ and
PHP_NORMAL_READ. The latter is useful to get lines instead of raw data.
But using it will result in a blocked socket, regardless of
socket_set_nonblock() has been used.

I'm not sure this is a bug. If it is not, the manual page should
mention that the socket_read function would block regardless of
blocking mode if the PHP_NORMAL_READ parameter is used.

Reproduce code:
---------------
// short example
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_nonblock($socket);
socket_connect($socket, $host, $port);
$data = socket_read($socket, 512, PHP_NORMAL_READ);

Expected result:
----------------
Let's assume no data is transmitted by the remote host, thus no data is
to be received. Since we set non-blocking mode, the socket_read function
should produce a socket error very quickly and the script execution
continues.

Actual result:
--------------
Instead of continuing script execution, the socket_read function blocks
the further execution, waiting for data to be read until its buffer is
full. Thus it shows the effect of blocking mode, even though we
explicitly set to non blocking mode.


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


-- 
Edit this bug report at http://bugs.php.net/?id=33471&edit=1

Reply via email to