|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-07-24 16:31 UTC] jason@php.net
[2002-09-11 11:37 UTC] sniper@php.net
[2002-09-11 11:47 UTC] webmaster at darkenemy dot com
[2002-09-25 09:19 UTC] jason@php.net
[2002-09-25 09:25 UTC] webmaster at darkenemy dot com
[2002-10-05 09:12 UTC] wez@php.net
[2004-11-06 16:46 UTC] techtonik@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
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"; ?>