PHP 4.0 Bug #6621 Updated: Socket handling is not working correctly.

From: Date: Fri, 08 Sep 2000 12:11:07 +0000
Subject: PHP 4.0 Bug #6621 Updated: Socket handling is not working correctly.
Groups: php.dev 
Request: Send a blank email to php-dev+get-32650@lists.php.net to get a copy of this message
ID: 6621 User Update by: csa@elogica.com.br Status: Open Bug Type: *Network Functions Description: Socket handling is not working correctly. I was trying to make a webchat connecting to an IRC server, but I was getting problems with the connection. It connected OK, but I can't write ANYTHING. When I submit (input.php) text to be sent to the server, it just stalls. Then I got a ready-made script called phpChat, which used phpIRC to do the same thing. And it had the same problem. I tried also a free webhost that supplied MySQL and PHP4 and got the *same* problem. Then I was told that it was a PHP4 bug, and that it worked fine in PHP3 and even on PHP4 up to b3. I tested it on PHP 3.0.16 and it phpChat works FINE! There goes MY (very very simple) code: CONN.PHP: <?php session_start(); ?> <HTML><BODY> <?php session_register("buffer"); $fp = fsockopen("irc.elogica.com.br", 7000, &$errno, &$errstr); //set_socket_blocking($fp,0); if(!$fp) { echo "$errstr ($errno)<br>\n"; } else { session_register("fp"); fputs($fp,"NICK Teste\n"); fputs($fp,"USER Teste 1 2 :Teste\n"); while(!feof($fp)) { $linha = fgets($fp,128); if ($linha) echo str_replace("\n", "<br>\n", $linha); flush(); if ($buffer) { echo $buffer + "<br>\n"; $buffer = 0; } } fclose($fp); } ?> </BODY></HTML> INPUT.PHP: <?php session_start(); session_register("buffer"); session_register("fp"); ?> <HTML><BODY> <FORM ACTION="input.php" METHOD="POST"> Vamu lá: <input type="text" name="texto"> <input type="hidden" name="SID" value="<?=session_id()?>"> </FORM> <?php if ($texto) $buffer = $texto; flush(); if (isset($fp) && !feof($fp) && $texto) { fputs($fp, $texto + "\n"); fflush($fp); } ?> </HTML></BODY> My configure line: ./configure --with mysql --with-apxs --enable sysvshm --enable-sysvsem (it has the same problem without the SYSV stuff). phpChat and phpIRC can be found at http://www.phpwizard.net/ Previous Comments: --------------------------------------------------------------------------- [2000-09-08 01:59:49] csa@elogica.com.br I was trying to make a webchat connecting to an IRC server, but I was getting problems with the connection. It connected OK, but I can't write ANYTHING. When I submit (input.php) text to be sent to the server, it just stalls. Then I got a ready-made script called phpChat, which used phpIRC to do the same thing. And it had the same problem. I tried also a free webhost that supplied MySQL and PHP4 and got the *same* problem. Then I was told that it was a PHP4 bug, and that it worked fine in PHP3 and even on PHP4 up to b3. I tested it on PHP 3.0.16 and it phpChat works FINE! There goes MY (very very simple) code: CONN.PHP: <?php session_start(); ?> <HTML><BODY> <?php session_register("buffer"); $fp = fsockopen("irc.elogica.com.br", 7000, &$errno, &$errstr); //set_socket_blocking($fp,0); if(!$fp) { echo "$errstr ($errno)<br>n"; } else { session_register("fp"); fputs($fp,"NICK Testen"); fputs($fp,"USER Teste 1 2 :Testen"); while(!feof($fp)) { $linha = fgets($fp,128); if ($linha) echo str_replace("n", "<br>n", $linha); flush(); if ($buffer) { echo $buffer + "<br>n"; $buffer = 0; } } fclose($fp); } ?> </BODY></HTML> INPUT.PHP: <?php session_start(); session_register("buffer"); session_register("fp"); ?> <HTML><BODY> <FORM ACTION="input.php" METHOD="POST"> Vamu lá: <input type="text" name="texto"> <input type="hidden" name="SID" value="<?=session_id()?>"> </FORM> <?php if ($texto) $buffer = $texto; flush(); if (isset($fp) && !feof($fp) && $texto) { fputs($fp, $texto + "n"); fflush($fp); } ?> </HTML></BODY> My configure line: ./configure --with mysql --with-apxs --enable sysvshm --enable-sysvsem (it has the same problem without the SYSV stuff). --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6621

« previous php.dev (#32650) next »