Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pure PHP torrent client? [closed]

Tags:

php

bittorrent

I'm a developer for a PHP CMS and I want to add a BitTorrent capability to it. The CMS already lets users upload files which other users can then download, comment, etc. but I think this could be improved (especially for low-bandwidth sites) if the CMS could offer these downloads via BitTorrent, either via .torrent metadata files or via magnet links, so that the upload burden is shared.

It seems pretty straightforward, since there are loads of existing trackers out there I could plug in to, and the process of creating the required metadata is well documented, but the final piece of the puzzle is getting the site to act as a seed for the files, in case nobody else is seeding (eg. when it's newly added). I've spent a while searching, but can't find any PHP code which will seed files via BitTorrent, either via a tracker or via the DHT. There are plenty of frontends for torrent applications like rtorrent, Vuze, etc. but I'm looking for pure PHP, as I don't want to introduce dependencies which can't be satisfied by users on crappy, locked-down shared hosting accounts. Does anyone know of any PHP code capable of this floating around, or will I have to roll my own?

like image 486
Chris Warburton Avatar asked Jan 01 '11 21:01

Chris Warburton


2 Answers

well what you want is theoretically possible.

there are some burdens like named virtual hosts and wrong listeing ports and execution time limits but you could theoretically follow the specs and do everything in php. you can open sockets and write raw data to it so theoretically anything is possible.

but its totally absurd and senseless.

however your problem is not new and there are solutions for that.

they are called propagating cdns.

most of them provide edgecasting for delivering content with high speed and low latency (this is the usual use case), but you can also use them to balance traffic.

most cdns of coruse cost money.

but there is a project devoted to this very specific problem. to cache content and deliver it for low bandwidth sites and only fetch it from there.

its called the coral cdn, you should check it out. the probably most used commercial ones are akamai, cachefly, and level3.

like image 161
The Surrican Avatar answered Nov 05 '22 22:11

The Surrican


In the long run you HAVE to have your own server for this, because you need to run a torrent client on your server with your file(s) and (a) seed(s)? Then you could access via php, it would be fast and easy. I have done this with Transmission for a Linux server.

like image 20
Eric Sebasta Avatar answered Nov 05 '22 21:11

Eric Sebasta