Can a browser communicate with another browser on the same network directly?
browser, html, javascript, p2p, webrtc
Solution
Yes, you can establish a direct connection between two browsers over the local network using WebRTC. It requires the use of ICE, but that does not mean that an outside STUN or TURN server is needed. If the browsers are on the same network, ICE will succeed with only the local candidates of each browser.
STUN/TURN is needed only in order to guarantee that two endpoints can establish a connection even when they are in different networks and behind NATs.
In fact, if you use most of the WebRTC example applications (such as apprtc) with two browsers connected in a local network, ICE is most likely to select and use the pair of local addresses. In this case a channel allocation on a TURN server will be made, but it will not get used.
In your WebRTC application, you can disable the use of STUN/TURN by passing empty iceServers when you create the PeerConnection.
Problem
I'm playing around trying to find a way to communicate between two browsers on the same network to establish WebRTC without a server roundtrip (no STUN/ICE/TURN). Basically an alternative to the approach found here, where the "handshake" is done via copy/mail/pasting. After sifting through all the cross-browser-communication examples I could find (like via cookies or WebTCP) plus a bunch of questions on SO (like here), I'm back to wondering a simple thing: Question: If Alice and Bob visit the same page `foo.html` while on the same network and they know each others' internal assigned IP addresses, are there any ways they can communicate purely with what is available on the browser? This excludes non-standard APIs like Mozilla TCP_Socket_API, but other than that all "tricks" are allowed (img tags, iframes, cookies, etc.). I'm just curious if I can listen to someone on the same network "broadcasting" something via the browser at all. Edit: `foo.html` will be on static server, no logic, no ICE, no shortcut. Edit: Still not a solution but a websocket server as Chrome extension comes closer. Example here: almost pure browser serverless WebRTC