how to get a peer list with libtorrent?

Suggestions and discussion of future versions
Post Reply
vkefallinos

how to get a peer list with libtorrent?

Post by vkefallinos »

hello to everyone in this forum.
i want to use python-libtorrent to get a list of peers connected to a torrent.

I have tried this code :
import libtorrent as lt
import time
ses = lt.session()
ses.listen_on(6881, 6891)
info = lt.torrent_info('test.torrent')
h = ses.add_torrent({'ti': info, 'save_path': './'})
print 'starting', h.name()
while (not h.is_seed()):
s = h.status()
p = h.get_peer_info()

print lt.peer_info().ip

sys.stdout.flush()

time.sleep(15)

print h.name(), 'complete'
and it prints this:
starting test.avi
('0.0.0.0', 0)

('0.0.0.0', 0)
.
.
.
so instead of giving me a peer list it gives me zeros.Am i doing something wrong?
Post Reply