PHP 4.0 Bug #6621: Socket handling is not working correctly.
| From: | csa at elogica dot com dot br | Date: | Fri, 08 Sep 2000 05:59:49 +0000 |
| Subject: | PHP 4.0 Bug #6621: Socket handling is not working correctly. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-32636@lists.php.net to get a copy of this message | ||
From: csa@elogica.com.br
Operating system: Linux RH 6.2 and others
PHP version: 4.0.2
PHP Bug Type: *Network Functions
Bug 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).