ID:               27494
 User updated by:  csaba at alum dot mit dot edu
 Reported By:      csaba at alum dot mit dot edu
 Status:           Bogus
 Bug Type:         Output Control
 Operating System: Win2K
 PHP Version:      4.3.4
 New Comment:

Thanks for the feedback, you are correct.  I'm adding this in case
anyone wanders into this and wanders about it:

The problem was due to javascript.  By replacing the line which
continues to reset the javascript (...scripts[0].src = ...) source with
a "timeout" construct the problem was resolved.  Evidently, multiple
browsers did not like initiating a replace until the prior javascript
had finished loading.



Csaba


Previous Comments:
------------------------------------------------------------------------

[2004-03-06 13:33:30] [EMAIL PROTECTED]

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Support request are to be addressed of PHP's general 

mailing list, not the bug system. 

------------------------------------------------------------------------

[2004-03-04 08:48:19] csaba at alum dot mit dot edu

Description:
------------
I'm way sorry for posting this here since the culprit is unclear, but
you guys have the best response.  I've written a (non polling) script
to simulate sockets on localhost.  Web page A at
http://localhost/test/In.php is a page that the user enters some text
with and it gets written into a file.



Meanwhile, web page B at http://localhost/test/Out.php is looking at
this file and when it changes, it will update web page B with the new
text.  This is working fine.



Now introduce web page C at the same http://localhost/test/Out.php  In
this case, the second page of B and C to be user refreshed/invoked will
notice the change from page A, and after that it stops refreshing,
too.



Something is clearly wrong, but is it PHP 4.3, Apache 2.0.43, IE 5.5,
or (gasp) my code?  I have also coded file_get_contents manually with
the same results.

Reproduce code:
---------------
In the test directory have 3 files:

In.php:

<?php $newWord = @$_POST["newWord"]; ?>

<html>

<head><title>Input page</title></head>

<body>

<form method=post>

<table><tr><td>Enter a word: </td>

<td><input name=newWord value='<?php print($newWord); ?>'></td></tr>

<tr><td>&nbsp;</td><td><input type=submit></td></tr>

</table>

<?php if($_SERVER["REQUEST_METHOD"]=="POST") {

    $fh = fopen("myWord.txt", "w");

    fwrite ($fh, $newWord);

    print("submitted: $newWord");

}

?>

</form></body></html>





Out.php:

<html>

<head><title>Output page</title>

<script type='text/javascript'>

function openSocket() { document.scripts[0].src = "socket.php"; }

</script>

</head>

<body onLoad='openSocket()'>

Your output word is:

<div id=myWord><?php print(file_get_contents("myWord.txt")); ?></div>

</body>

</html>



Socket.php

<?php header("Content-Type: text/javascript; charset=ISO-8859-1");

$txt = file_get_contents("myWord.txt");

for ($ctr=1;$ctr<15;++$ctr) {

    $newTxt = file_get_contents ("myWord.txt");

    if ($newTxt!=$txt) {

        print ("top.document.getElementById('myWord').innerText =
'$newTxt';\r\n");

        print ("document.scripts[0].src = 'socket.php';\r\n");

        die();

    }

    sleep(1);

}

print ("document.scripts[0].src = 'socket.php';\r\n");

Expected result:
----------------
What I expect to have happen is that when multiple browser windows are
aimed at http://localhost/test/Out.php that they will all update right
away when In.php changes the contents of myWord.txt

Actual result:
--------------
Only the latter of the two Out.php windows is updated a single time.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27494&edit=1

Reply via email to