Browser to browser communication without a server?

笑着哭i 提交于 2019-12-03 09:04:21

问题


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)?


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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




回答5:


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

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



回答6:


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.




回答7:


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..




回答8:


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



来源:https://stackoverflow.com/questions/3283716/browser-to-browser-communication-without-a-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!