<p>I've always wanted a way to make a socket connection to a server and allow the server to manipulate the page DOM.  For example, this could be used in a stock quotes page, so the server can push new quotes as they become available.  </p>

<p>I know this is a classic limitation (feature?) of HTTP's request/response protocol, but I think this could be implemented as a Firefox plugin (cross-browser compatibility is not important for my application).  Java/Flash solutions are not acceptable, because (as far as i know) they live in a box and can't interact with the DOM.  </p>

<p>Can anyone confirm whether this is within the ability of a Firefox plugin?  Has someone already created this or something similar?  </p>

[{'answer_id': 13351, 'author': 'John Downey', 'author_id': 200, 'author_profile': 'https://Stackoverflow.com/users/200', 'pm_score': 3, 'selected': True, 'text': '<p>You may want to look at <a href="http://en.wikipedia.org/wiki/Comet_(programming)" rel="nofollow noreferrer">Comet</a> which is a fancy name for a long running HTTP connection where the server can push updates to the page.</p>\n'}, {'answer_id': 13395, 'author': 'Nickolay', 'author_id': 1026, 'author_profile': 'https://Stackoverflow.com/users/1026', 'pm_score': 0, 'selected': False, 'text': '<blockquote>\n  <p>You may want to look at Comet</p>\n</blockquote>\n\n<p>a.k.a. <a href="http://ejohn.org/blog/streaming-http-server-push/" rel="nofollow noreferrer">server push</a>. This does not let the server "update" the client page directly, but all the new data is sent to the page through a single connection.</p>\n\n<p>Of course, a Firefox <a href="http://developer.mozilla.org/en/docs/Extension" rel="nofollow noreferrer">extension</a> (as well as <a href="http://developer.mozilla.org/en/docs/Plugins" rel="nofollow noreferrer">plugins</a>, which are binary libraries that can do whatever any other application can do) can work with sockets too. See <a href="http://www.xulplanet.com/tutorials/mozsdk/serverpush.php" rel="nofollow noreferrer">1</a>, <a href="http://www.xulplanet.com/tutorials/mozsdk/serverpush.php" rel="nofollow noreferrer">2</a>.</p>\n'}, {'answer_id': 13487, 'author': 'pc1oad1etter', 'author_id': 525, 'author_profile': 'https://Stackoverflow.com/users/525', 'pm_score': 2, 'selected': False, 'text': '<p>It should be possible.  I have developed a xulrunner application that connects to a TCP server using sockets.  Extension development would likely have the same capabilities.  I used a library from mozdev - <a href="http://jslib.mozdev.org/" rel="nofollow noreferrer">JSLib</a>.  Specifically check out the <a href="http://jslib.mozdev.org/libraries/network/network.html" rel="nofollow noreferrer">networking code</a>.  The fact that there is a <a href="https://addons.mozilla.org/en-US/firefox/search?q=jslib&amp;cat=all" rel="nofollow noreferrer">Firefox add-on for JSlib add-on for Firefox</a> makes more more confident.</p>\n\n<p>Essentially, as I understand it, sockets are not part of JavaScript, but through XPCOM, you can get raw socket access like you would in any c/c++ application.  </p>\n\n<p>Warning:  <em>JSLib doesn\'t seem to receive a lot of attention and the mailing list is pretty sparse.</em>  </p>\n'}, {'answer_id': 12466445, 'author': 'Beachhouse', 'author_id': 783004, 'author_profile': 'https://Stackoverflow.com/users/783004', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>Java/Flash solutions are not acceptable, because (as far as i know)\n  they live in a box and can\'t interact with the DOM.</p>\n</blockquote>\n\n<p>That\'s not actually true of Java.  You can interact with Java via JavaScript and make DOM changes.</p>\n\n<p><a href="http://stephengware.com/proj/javasocketbridge/" rel="nofollow">http://stephengware.com/proj/javasocketbridge/</a></p>\n\n<p>In this example there are two JavaScript methods for interaction</p>\n\n<p>Send:</p>\n\n<p><code>socket_send("This was sent via the socket\\n\\n");</code></p>\n\n<p>Receive: </p>\n\n<p><code>on_socket_get(message){ more_code(message); }</code></p>\n'}]
['https://Stackoverflow.com/questions/13345', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']