I want to deliver a web page to the user that will reflect a change immediately (under a second) when a specific file (say myWord.txt) or database entry has changed on the server. Polling (refreshing the client's web page) every half second is not desireable.
One approach to this problem is to create an IFrame on the client's page and then have the server deliver incomplete javascript. Because the javascript is incomplete, the client/server connection stays alive. Every half minute or so, the server can kick out a javascript no-op to let the client know it's still alive (and note that the client executes each javascript line as it comes in from the server). All this should be transparent to the user. This allows the server to stream to the client as it sees fit. Meanwhile, the php code on the server could just be in a loop, and every half second or so checks on the status of the file in question. If it notices a change, then the javascript that it streams to the client will actually have some noticable effect.
I don't like this idea of looping, however, and I'm wondering if there's some functionality within PHP that can act as a trigger within this context. Sort of like a sleep_until function. Note that it is insufficient to have an external script run (via a chron job) because that would be external to the script communicating with the client page on the browser.
Thanks for any ideas. Ultimately, what I'm looking for is the cleanest solution to my original problem as opposed to using a specific approach. But polling from the client is not sufficient, and to give an idea, there will eventually be a few hundred client machines.
Csaba Gabor