ID: 36384 User updated by: djgrrr at gmail dot com Reported By: djgrrr at gmail dot com -Status: Closed +Status: Bogus Bug Type: Streams related Operating System: Linux 2.6 PHP Version: 4.4.2 New Comment:
>.< Previous Comments: ------------------------------------------------------------------------ [2006-02-13 21:41:54] djgrrr at gmail dot com sorry guys, this was my stupidity, not a bug at all :P ------------------------------------------------------------------------ [2006-02-13 19:08:56] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5.1-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.1-win32-latest.zip ------------------------------------------------------------------------ [2006-02-13 17:46:58] djgrrr at gmail dot com Description: ------------ when sending text through a socket, opened with fsockopen() or stream_socket_client() (in the case of php5) if you send more than aproximately 10 lines (with \r\n or \n as the EOL) all at once, it will begin to buffer after the 10 lines are sent to be writen with fwrite; It does not matter what the blocking setting, or the stream timeout setting is set at. The script will not block and will continue executing like normal, reading from the socket is instant and never buffers, so basically, you have a socket that can recive and process data extreamly fast, but is not able to write back to the stream at the same speed. Reproduce code: --------------- <?php $s = fsockopen("localhost",23); stream_set_timeout($s,0,95000); stream_set_blocking($s,false); stream_set_write_buffer($s,0); $i = 0; while ($i < 1000) { $i++; if (feof($s)) break; $in=trim(fgets($s,4096)); if ($in != "") { usleep(5000); // do some processing here } fwrite($s,"hello $i\r\n"); } ?> Expected result: ---------------- i expect it to write "hello #\r\n" where # is 1-1000 to the socket very fast (at least once every 0.1 seconds) Actual result: -------------- it will write around 10 lines to the socket very quickly, then will start to buffer at around 1 line per second, which in the case where you need results to come back very fast, it makes it quite annoying to deal with ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36384&edit=1