Pure PHP torrent client?

I am a PHP CMS developer, and I want to add the BitTorrent feature to it. CMS already allows users to upload files that other users can upload, comment, etc., but I think it can be improved (especially for sites with low bandwidth) if CMS can offer these downloads via BitTorrent, or through .torrent metadata files, either through magnetic links, so the burden of downloading will be shared.

This seems pretty simple, since there are many existing trackers that I could connect to, and the process of creating the necessary metadata is well documented, but the last piece of the puzzle is to make the site act like a seed for files if no one sowed (for example, when it was recently added). I spent some time searching, but I can’t find the PHP code that will process the files through BitTorrent, either through the tracker or through DHT. There are many interfaces for torrent applications, such as rtorrent, Vuze, etc., but I'm looking for pure PHP, since I do not want to introduce dependencies that cannot be satisfied by users on crappy, blocked shared hosting accounts, Someone Does anyone know of any PHP code capable of this float, or will I have to roll on my own?

+6
php bittorrent
source share
5 answers

Well, what you want is theoretically possible.

there are some burdens such as named virtual hosts and incorrect port lists and runtime restrictions, but you can theoretically follow the specifications and do everything in php. you can open sockets and write raw data into it, so theoretically anything is possible.

but its completely absurd and pointless.

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

they are called pervasive cdns.

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

most cdns of coruse cost money.

but there is a project dedicated to this very specific problem. cache content and deliver it to sites with low bandwidth and receive only from there.

it is called coral cdn , you have to check it out. probably the most commonly used commercial ones are akamai, cachefly and level3.

+3
source share

In the end, you have your own server for this, because you need to run a torrent client on your server with your files and (a) seeds? Then you can access through php, it would be quick and easy. I did this using a transfer for a Linux server.

+1
source share

I do not see this work for PHP. If I understand what you want to do correctly, this will not work at all on shared hosting due to the time limit during which the PHP script can work.

Any process of downloading or downloading torrents, which takes longer than the allowed 30 or 60 seconds, will have to go to the next page, reconnect and restart the action. I do not see how this can work.

I think the best thing you can do in PHP is a file on a torrent site that takes care of sowing. Clearbits (used by SO to provide the expected data dump) may be a useful service for this (but it is not free.)

0
source share

You can go through the time limit set by PHP by default in the php.ini file. However, if your hosts detect this, they may block your account. Most hosting providers will block your account if you use more than 3% of computer resources. Trying to write a bitient client in PHP is absurd if you don't have a dedicated machine to run it.

add this to your configuration file or any file that is included in each request.

// A Timeout of 5 minutes ini_set('max_execution_time', 300); 

Please note that you must specify the time in seconds if you do not do something like the following

 $timeout_minutes = 5; ini_set('max_execution_time', 60 * $timeout_minutes); 
0
source share

Maybe I'm late, but you can use Amazon S3 for this. (Not just a typical website.)

see the document here: http://docs.aws.amazon.com/AmazonS3/latest/dev/S3Torrent.html

You simply upload files from a shared server to S3, then distribute the torrent file and pay only for the outgoing bandwidth from S3.

-one
source share

All Articles