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

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
  • To all of those asking why, I was interested to see if there was a solution for simple/quick file transfer over lan without the user downloading anything. – CodyJames.LeBlanc Jul 19 '10 at 18:27

8 Answers8

9

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

Phylodome
  • 151
  • 1
  • 5
3

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
Jonas
  • 4,683
  • 4
  • 45
  • 81
  • 1
    This is using the httprelay.io site as a server. The question is about a peer-to-peer connection without a server. – Al Sweigart Jan 05 '21 at 19:26
  • Even WevRTC is using servers in many cases. httprelay.io is a much less complicated solution. – Jonas Jan 07 '21 at 07:34
1

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

1

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.

guns
  • 10,550
  • 3
  • 39
  • 36
  • +1 interesting. But it doesn't make a direct connection, it uses opera servers to get around NAT restrictions (really the only smart way to do this anyhow) http://www.jorgemarsal.com/blog/2009/06/16/how-does-opera-unites-file-sharing-service-work/ – Byron Whitlock Jul 19 '10 at 18:19
  • Ah, I see. I had assumed it was using zeroconf/Bonjour for resolving local clients. Oh well, maybe some day in the future it will be done with node.client.js + CouchDB or something fun like that. – guns Jul 19 '10 at 18:31
1

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.

3Dave
  • 28,657
  • 18
  • 88
  • 151
0

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.

Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
0

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

moongoal
  • 2,847
  • 22
  • 23
0

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

Ben Usman
  • 7,969
  • 6
  • 46
  • 66