Suppose I'm synchronizing text on an HTML page, stored in localStorage from computer A to computer B. When the user edits the text on computer A, I send a request to the server, and tell it what text changed. Is there any way that I can get the server to tell computer B that there's new text, without computer B having to keep checking? I've read about Comet, but I'm trying not to use any libraries. Is there a way? Also, if you're going to suggest Comet, could you give a simple example using plain JavaScript and Comet?
I had an idea, but I don't know if it'd work. On computer B, I send a request once, and let the server's file keep delaying the response till there is some new text. That way, it'd be like long-polling, but the request would eventually timeout. If there was a way to set the timeout to be never, this would get much easier. So, anyone have any ideas?
P.S.- I want to use only JavaScript and PHP and try avoid using libraries. Still, if you know of a library that can do this with JS and PHP, please tell me anyway.
Also, I know there have been questions like this, but the answers I found there weren't satisfactory.
Oh, and if anyone knows how the chat over here works, could you tell me that as well?
tl;dr: I want to send a request from a server to an HTML page, or have the HTML send a single request which is kept alive till an appropriate response is created.