views:

1778

answers:

4

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.

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.

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

+2  A: 

You may want to look at Comet which is a fancy name for a long running HTTP connection where the server can push updates to the page.

John Downey
A: 

You may want to look at Comet

a.k.a. server push. 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.

Of course, a Firefox extension (as well as plugins, which are binary libraries that can do whatever any other application can do) can work with sockets too. See 1, 2.

Nickolay
A: 

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 - JSLib. Specifically check out the networking code. The fact that there is a Firefox add-on for JSlib add-on for Firefox makes more more confident.

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.

Warning: JSLib doesn't seem to receive a lot of attention and the mailing list is pretty sparse.

pc1oad1etter
A: 

@pc1oad1etter: Sir could you provide us the sample extension you have done using this JSLib, thanks in advance