Bug #18373 Updated: unread_bytes always 0

From: Date: Wed, 24 Jul 2002 20:31:09 +0000
Subject: Bug #18373 Updated: unread_bytes always 0
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15077@lists.php.net to get a copy of this message
ID: 18373 Updated by: jason@php.net Reported By: webmaster@darkenemy.com -Status: Open +Status: Feedback Bug Type: Sockets related Operating System: Windows Server Platform PHP Version: 4.2.1 New Comment: fsockopen() has changed dramaticly in current CVS with the introduction of streams. Would you mind trying a snapshot to see if your problem still persists? snaps.php.net/win32/ Thanks, -Jason Previous Comments: ------------------------------------------------------------------------ [2002-07-16 12:35:35] webmaster@darkenemy.com After creating a blocking socket with fsockopen, I entered an idle loop. I've checked the property unread_bytes of the array returned by socket_get_status. After I got a value of zero bytes, socket_get_status reports always an unread buffer of zero bytes, also when the server sends any data. I checked the server logs and I checked the script without checking socket status. Without checking the socket status, it works wonderful. Sample script: <?php echo "<html><body><pre>\n"; set_time_limit(0); $sock = fsockopen("localhost",6667,$errno,$errstr,30); // Connecting to dummy ircd fputs($sock,"NICK PreProcessor\r\n"); fputs($sock,"USER PHP localhost localhost :HyperText Pre Processor\r\n"); while (!feof($sock)) { // Loop until connection will be closed $stat = socket_get_status($sock); $queue = $stat[unread_bytes]; // How many bytes to read from socket? if ($queue > 0) { $data = chop(fgets($sock,128)); echo $data."\r\n"; flush(); $foo = split("[:]",$data); if ($foo[0] == "PING ") fputs($sock,"PONG :$foo[1]\r\n"); $foo = split("[ ]",$data); if ($foo[1] == "005") fputs($sock,"JOIN #Channel\r\n"); if ($foo[3] == ":die") fputs($sock,"QUIT :EOF\r\n"); // retrieved shutdown script } else { sleep(1); // Sleep one second and do other things } } fclose($sock); // Good bye ... echo "</pre></body></html>\n"; ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18373&edit=1

« previous php.bugs (#15077) next »