Magnus
Magnus

Reputation: 18788

Is it possible to send data between two browsers on different machines (but on same WLAN) using no servers?

Ultimately what I would like to to is build a Javascript app that runs in the browser, and is able to communicate to other users running the same Javascript app on other machines within the same network. I've been reading up on and playing around with Websockets and webRTC, but they both require a server at some stage of the connection process. I have also looked at PeerJs and OpenPeer, but they too seem to rely on webRTC which in turn requires an intermediate server to setup the connection.

If the users are not connected to the Internet (or to a network running a local server) it doesn't seem possible to use either of the above techniques, right?

Basically what I'm thinking is this:

  1. User A and User B are on two separate machines on the same LAN/WLAN, not connected to the Internet.
  2. User A opens up the app/page in his browser.
  3. User B opens up the app/page in his browser.
  4. User A enters User B's local IP address in a textbox and clicks on "Connect".
  5. User A and User B can now send messages to each other.

Is this possible today? Or is there something being developed that would enable this in the near future?

Upvotes: 1

Views: 2259

Answers (2)

Adonis Gaitatzis
Adonis Gaitatzis

Reputation: 3739

I know this is an old question, but in case someone finds it relevant:

Today this is possible using WebRTC, a JavaScrip, peer-to-peer, real-time communication protocol.

A library that's available at the time of writing is PeerJS, which supports most browsers, for now except Safari.

PeerJS handles some of the complicated, behind-the-scenes stuff related to NAT and firewalls so that you can send data between two JavaScript clients.

Upvotes: 1

adamb
adamb

Reputation: 4883

This is not possible to do directly inside of a browser.

Standard HTTP interaction is based on a request-response model. Web browsers act as the client, sending requests. They are not designed to be able to handle HTTP requests and send responses accordingly, that job belongs to a server.

Upvotes: 1

Related Questions