|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-09-08 01:59 UTC] csa at elogica dot com dot 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 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).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
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/