quilby
quilby

Reputation: 3271

Is it possible to build a torrent client using only HTML(5) and JavaScript?

There isnt much more to add. Is it possible to build a torrent client using only HTML and JavaScript. You can not use things like Java, ActiveX, NaCl... If yes, please give a high level description.

I dont have much knowledge about front end dev, but I think websockets will be able to do the networking (is it possible to connect one client to another without having all data go through a server?). I know that you cant write files using JavaScript so I think the file thats being downloaded will either have to be saved completely in the memory, or the client will have to use one of the new APIs in HTML5 for storing content.

Upvotes: 48

Views: 24971

Answers (7)

Laurent VB
Laurent VB

Reputation: 1207

There's a recent implementation based on WebRTC that works in node and the browser: https://github.com/feross/webtorrent

Upvotes: 19

kzahel
kzahel

Reputation: 2785

There's no good reason why this can't be done today. BitTorrent/uTorrent both have code to support websocket connections with binary frames. However, they are currently compiled without support (due to political/product reasons I think). I used to work at BitTorrent and another engineer (Arty) wrote the support. For a while it was really cool being able to download torrents onto iPads from mobile Safari. (saving directly to Google Drive funnily enough)

HTTP trackers could be configured to send Access-Control-Allow-Origin headers.

Also the tracker announce protocol could use a bit in the "key" field to indicate that the client accepts websocket connections. Then a special argument like "typewant" could indicate that the announce response should only return clients who have sent that bit.

The tracker protocol could also be extended similarly to support negotiation of WebRTC P2P DataChannel connections, so that connections could be made directly browser<->browser.

For now, we have the chrome.socket platform API, and jstorrent, a chrome packaged app (designed for ChromeOS mainly)

Upvotes: 10

Daniel Nordstr&#246;m
Daniel Nordstr&#246;m

Reputation: 41

I'm late to the party, but since this question is still among the top on Google's results, I'll answer anyway.

You may write BitTorrent-related web apps or browser extensions with Btapp.js, which uses a Javascript interface provided by BitTorrent Torque. When you call the connect method, the user will be prompted to install BitTorrent Torque, that's all. Some cool stuff going on if you check out existing projects using it—streaming media, drag-and-drop sharing, etc.

As for solutions without any dependency, the ones mentioned by Nick Russler still seem to be the only feasible options.

Upvotes: 4

CAFxX
CAFxX

Reputation: 30301

You can't with WebSockets because those are strictly client-server. But the upcoming WebRTC standard, while being mostly targeted at audio/video conferencing, has a provision for generic client-client data transfers. If this provision makes it to the final version, then you'll have a viable way to implement generic peer-to-peer data transfers between browsers.

Upvotes: 9

Yahor
Yahor

Reputation: 671

This is possible using Chrome Apps APIs: chrome.socket and chrome.fileSystem.

There is at least one pure JavaScript implementation for Google Chrome: JSTorrent.

Upvotes: 17

user166390
user166390

Reputation:

No. It's not.

This is because the WebSocket specification falls outside of HTML5 and JavaScript ;-) That being said, opening up the question to "using features supported natively in [progressive/upcoming] browsers" then...

...still no :-)

This is because WebSocket requires a special handshake to setup with restrictions. It's not a free-for-all open-TCP-fest. The approach would require either

  1. clients to be modified to accept WebSocket requests (as well as dealing with any cross-site access issues)

  2. or, more realistically, a server to bounce through

Upvotes: 33

Related Questions