Peer-To-Peer File Sharing with Web Sockets

Peer-to-peer file sharing with Web Sockets

To allow files to be shared without the need to upload it to the server, (i.e Coworkers) you can now use the WebRTC DataChannel API, to create a peer to peer connection.

Does HTML5 Support Peer-to-Peer (and not just WebSockets)

See the answers for Will HTML5 allow web apps to make peer-to-peer HTTP connections? However, the content in the WebSockets specification seems to have gone, so I suspect the answer now is "no".

Will HTML5 allow web apps to make peer-to-peer HTTP connections?

Instead of intelligent guesses, here is an informed answer:

HTML 5 plans to allow peer to peer connections from javascript, but these connections WILL NOT BE RAW TCP.

The complete spec can be found at http://dev.w3.org/html5/websockets/

jrh

EDIT: with specific reference to peer to peer connections, check out these links:

  • Regarding peer to peer connections: http://www.w3.org/TR/2008/WD-html5-20080122/#peer-to-peer
  • Regarding broadcast connections to the local network: http://www.w3.org/TR/2008/WD-html5-20080122/#broadcast
  • Regarding TCP connections (in the encoded protocol): http://www.w3.org/TR/2008/WD-html5-20080122/#tcp-connections
  • Complete proposed spec: http://www.w3.org/TR/2008/WD-html5-20080122/#network

Its important to note that the capabilities are still being negotiated. It will be nice to be able to create "local chat" web apps :)

jrh

Do websockets allow for p2p (browser to browser) communication?

No. Browsers can only initiate WebSockets connections, not receive them. The W3C browser API spec only defines how to start an outbound connection.

You can make an application that would both initiate and accept WebSockets connections, but browsers do not do this.

You might look at Pusher App which you could use to build a WebSockets application with multiple clients. The service provides up to 20 simultaneous WebSockets clients for free (you can pay for higher scaling).

Update:

The WebRTC protocol and API is making rapid progress and allows a Data Channel to be established between two peers (you still may need a STUN/TURN server for the initial NAT traversal and setup).

Peer to Peer web API on the same network

You can use the data-channel of WebRTC:

http://www.webrtc.org/

or you can set up a server and use WebSockets:

https://en.wikipedia.org/wiki/WebSocket

Drawbacks:

For WebRTC you will need a STUN server as I understood it, that will exchange the IP-addresses you use. For the rest the comminication is peer-to-peer.

It's currently scarce with examples on WebRTC as it is still in development. Only Chrome and Firefox (nightly) supports the protocol.

html5rocks has written a nice introduction on this (too much to paste in here):

http://www.html5rocks.com/en/tutorials/webrtc/basics/

For WebSockets you need a web server that function as a hub. This is however simple to set up as it uses the standard HTTP protocol. If you're on the .Net platform you can use for example SignalR which is easy to get up and running.

Note that for WebSocket it must initially be same-origin. This is however possible to circumvent (CORS). Typically the script using WebSockets is within the same web page and will communicate also with the same domain it was loaded from.

There are other options for WebSockets that use can use with node.js, socket.io, ruby and so forth.

UPDATE:

If you don't have a server peer-to-peer is gonna be difficult with plain html5. You will have to have something that negotiates the connections.

You can work around this by setting up a server locally on your computer and allow the other person to connect to that directly.

See for example this (free open-source TURN/STUN server):

http://code.google.com/p/rfc5766-turn-server/

Note: this server targets *NIX. I couldn't find a free solution for Windows if that's what you're using. There are commercial solutions as another option.

HTML5 peer to peer video?

if you are talking about webrtc the draft can be found here

w3c webrtc draft



Related Topics



Leave a reply



Submit