From: info at goldenelite dot com Operating system: FreeBSD 4.10 PHP version: 5.0.4 PHP Bug Type: Sockets related Bug description: socket_read PHP_NORMAL_READ blocks socket
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 bug report at http://bugs.php.net/?id=33471&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33471&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33471&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33471&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33471&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33471&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33471&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33471&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33471&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33471&r=support Expected behavior: http://bugs.php.net/fix.php?id=33471&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33471&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33471&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33471&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33471&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33471&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33471&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33471&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33471&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33471&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33471&r=mysqlcfg