开发者

Browser to browser communication without a server?

Is there any 开发者_开发百科possible way to have browsers communicating to each other over lan/wan without the use of a server (direct peer-to-peer)?


Looks like there may be hope on the horizon: http://www.w3.org/TR/webrtc/


Yes you can try http://httprelay.io with the AJAX calls. It is simple as that:

* Send data: POST https://demo.httprelay.io/link/your_secret_channel_id
* Receive data GET https://demo.httprelay.io/link/your_secret_channel_id


IIRC, Opera released some kind of addition to their browser that embedded a webserver for just that functionality:

http://unite.opera.com/

Not sure it really went anywhere, but I think its time will come.


In pure HTML/Javascript? Probably not.

To my knowledge, there's no good way in native JavaScript to listen for connections. In HTTP, the client opens a port, sends a request, and receives a response. You could use the XHTTP or similar class to make a request but there's no good way within a normal web page to create a server on the other end that would listen for requests.

Given that, I know that Flash provides a socket library that allows you to listen for connections. (I imagine Silverlight does this as well, though I haven't researched it.) If you were to create an object using either of these technologies, you could listen for connection requests from any client (assuming that you're not behind a firewall or some other connection-filtering device), maintain an open socket and send whatever you want over the wire.

Summary:

  1. Probably can't do this in JavaScript/HTML/CSS.

  2. BUT, you could pull it off in Flash or Silverlight.


If the browsers are behind firewalls you can look at using NAT traversal. Protocols like STUN and TURN are used by WebRTC to do this. This web site has some nice examples/tutorials HTML5 Rocks


Short answer: Nope. Not possible.

Long answer: You could write a signed java applet that implements a web server in each browser. Then browser "a" could talk to browser "b's" applet (don't' close that tab!). You would then have limited access to the others browser state in this way.

Similarly, you could write a plugin/addon that could accomplish much of the same thing.

The real question is why would you want to do this? what are you trying to accomplish? Answer that question and we might be able to come up with a solution.


Yes, they could, but they would need to be designed to establish the connection (or would need to have a module that does it).

Even if I'm wondering why would they need to..


Flash - Stratus. New stuff in latest flash that provides P2P connections.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜