Cómo escribir una aplicación Bittorrent simple?


Cómo escribir una aplicación bittorrent simple. Algo así como un" hola mundo " usando una biblioteca de bittorrent, me refiero a una aplicación más sencilla para entender el funcionamiento de bittorrent. Preferiría una implementación de python o C/C++, pero puede ser cualquier lenguaje. La plataforma tampoco es un problema, pero preferiría Linux.

Recomendaciones para la biblioteca a seguir, he descargado el código fuente de uno (creo que oficial bittorrent) de - http://sourceforge.net/projects/bittorrent/develop. Pero, veo un montón de otras bibliotecas en http://en.wikipedia.org/wiki/Comparison_of_BitTorrent_clients#Libraries. Agradecería recomendaciones sobre este.

Cómo probar una aplicación si todo lo que tienes es un portátil.

Author: Vivek Sharma, 2011-03-23

1 answers

Deberías probar libtorrent (rasterbar). http://libtorrent.org

Si quieres escribir tu cliente en python, en linux, instálalo con:

sudo apt-get install python-libtorrent

Un ejemplo muy simple de código python para usarlo para descargar un torrent:

import libtorrent as lt
import time
import sys

ses = lt.session()
ses.listen_on(6881, 6891)

info = lt.torrent_info(sys.argv[1])
h = ses.add_torrent({'ti': info, 'save_path': './'})
print 'starting', h.name()

while (not h.is_seed()):
   s = h.status()

   state_str = ['queued', 'checking', 'downloading metadata', \
      'downloading', 'finished', 'seeding', 'allocating', 'checking fastresume']
   print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
      (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
      s.num_peers, state_str[s.state]),
   sys.stdout.flush()

   time.sleep(1)

print h.name(), 'complete'
 75
Author: Arvid,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-05-29 22:46:37