ID: 22199 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Assigned +Status: Closed Bug Type: Sockets related Operating System: Suse Linux 7.2 PHP Version: 4CVS-2003-02-12 (stable) Assigned To: wez New Comment:
This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Fix will be in 4.3.1. Previous Comments: ------------------------------------------------------------------------ [2003-02-13 14:49:23] [EMAIL PROTECTED] Change summary, assign to me, patch pending. ------------------------------------------------------------------------ [2003-02-13 14:06:15] [EMAIL PROTECTED] Ok... here you go. While writing this script for you, i found the real problemmaker. But first the script: <?php # # Strange behavior of fgets() in conjunction with fputs() # $sock = fsockopen('217.160.132.63', 6667, $errno, $errstr, 30); if($sock) { echo "Connection established...\n"; // Services details $conpass = 'a_nice_password'; $servern = 'testing.xanaducorp.net'; $serverdsc = 'doing tests'; // Incomming-traffic logger details $ircNick = "log_printer2"; $bot_ident = "printer2"; $bot_name = "printer2"; $bot_host = "testing.xanaducorp.net"; $logchannel = '#services'; # Handshake with server fputs($sock, "PASS $conpass"."\n"); fputs($sock, "SERVER $servern 1 :$serverdsc"."\n"); fputs($sock, "CAPAB :"."\n"); fputs($sock, "SVINFO 3 1 0 :".time()."\n"); fputs($sock, "PONG ".time()."\n"); fputs($sock, "NICK $ircNick 1 ".time()." $bot_ident $bot_host $servern :$bot_name"."\n"); fputs($sock, ":$ircNick MODE $ircNick :+Si"."\n"); fputs($sock, ":$ircNick JOIN $logchannel"."\n"); fputs($sock, ":$servern MODE $logchannel +o $ircNick"."\n"); while($buffer = fgets($sock)) { echo $buffer; flush(); $i++; # # This fputs() is creating all the problems. I'll explain below # if($i==1) fputs($sock, ":$ircNick PRIVMSG $logchannel :".$buffer."\n"); } fclose ($handle); echo "Connection closed...\n"; } else { echo "$errstr ($errno)<br>\n"; } ?> As you can see, i did for testing purposes send all the text send from the irc server to my service to stdout and had a look at it. Everything was working great as long as i do not have a fputs() in the while-loop. When only submitting one single line in fputs() 125 lines of input from the server a simply lost. I will short output of both version: Without fputs(): Connection established... :irc.xanaducorp.net NOTICE AUTH :*** Looking up your hostname... :irc.xanaducorp.net NOTICE AUTH :*** Found your hostname (cached) [... additonal 122 lines ...] :Netvyper JOIN #xanadu.eve,#eve.beta,#eve NICK Cimager 1 1045158878 ~Twis cimager.xs4all.nl irc.xanaducorp.net 0 :Cim With fputs(): Connection established... :irc.xanaducorp.net NOTICE AUTH :*** Looking up your hostname... ~Twis cimager.xs4all.nl irc.xanaducorp.net 0 :Cim That is really strange. I hope this is what you did requested. ------------------------------------------------------------------------ [2003-02-13 11:48:23] [EMAIL PROTECTED] Suspending until you can provide the short, self contained, reproducing script we have requested. ------------------------------------------------------------------------ [2003-02-13 08:31:07] [EMAIL PROTECTED] Ok, as it seems the socket functions do work. So I will use them for now with PHP 4.3.x ... still the bug in fgets() is there. Trust me. It's not my stupidity. ------------------------------------------------------------------------ [2003-02-13 08:10:22] [EMAIL PROTECTED] Btw, i check SmartIRC, that [EMAIL PROTECTED] is using. Actually this class does not use fgets() at all, because it either uses real sockets or fread(). ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/22199 -- Edit this bug report at http://bugs.php.net/?id=22199&edit=1
