#36314 [NEW]: Incorrect behavior of socket_read when used with PHP_NORMAL_READ

From: Date: Tue, 07 Feb 2006 03:59:03 +0000
Subject: #36314 [NEW]: Incorrect behavior of socket_read when used with PHP_NORMAL_READ
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-92996@lists.php.net to get a copy of this message
From: flachi at gmail dot com Operating system: Windows PHP version: 4.4.2 PHP Bug Type: Sockets related Bug description: Incorrect behavior of socket_read when used with PHP_NORMAL_READ Description: ------------ I tested this also on Linux and it works ok. When I use socket_read with PHP_NORMAL_READ as third parameter it gaves me a warning and doesn't take into account the if the socket is blocking. I looked in the sources but I found nothing that would let me know why is this happening (maybe in php_read ?). I've seen that there are a lot of bugs with this function on Win32. A very good ideea would be to rewrite it from scratch. Reproduce code: --------------- $g = socket_create (AF_INET, SOCK_STREAM, SOL_TCP); socket_connect ($g, "helsinki.fi.eu.undernet.org", 6667); socket_set_block ($g); $s = "USER flachi flachi flachi :flachi\r\nNICK floadssaas\r\n"; socket_write ($g, $s, strlen ($s)); while (($s = socket_read ($g, 512, PHP_NORMAL_READ)) !== false) { echo $s; } socket_shutdown ($g, 2); socket_close ($g); Expected result: ---------------- This should connect to that IRC server and get some lines of code. Here is how it should work (and does on Linux): ~$ php -q test3.php NOTICE AUTH :*** Looking up your hostname NOTICE AUTH :*** Checking Ident NOTICE AUTH :*** Couldn't look up your hostname PING :34913160 Actual result: -------------- This is what I get on Windows. It doesn't receive anything from the IRC server. G:\Foo\fbot>php -d output_buffering=8 -d html_errors=off -q test.php PHP Warning: socket_read() unable to read from socket [0]: The operation completed successfully. in G:\Foo\fbot\test.php on line 8 -- Edit bug report at http://bugs.php.net/?id=36314&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36314&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36314&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36314&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36314&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36314&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36314&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36314&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36314&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36314&r=support Expected behavior: http://bugs.php.net/fix.php?id=36314&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36314&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36314&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36314&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36314&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36314&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36314&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36314&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36314&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36314&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36314&r=mysqlcfg

« previous php.bugs (#92996) next »