NAME

Net::BitTorrent::Tracker::UDP - UDP Tracker Protocol (BEP 15)

SYNOPSIS

use Net::BitTorrent::Tracker::UDP;

my $tracker = Net::BitTorrent::Tracker::UDP->new(
    url => 'udp://tracker.openbittorrent.com:80/announce'
);

# Announce
$tracker->perform_announce({
    infohash   => $bin_ih,
    peer_id    => $my_id,
    port       => 6881,
    downloaded => 0,
    uploaded   => 0,
    left       => 1024
}, sub ($res) {
    say 'Peers: ' . join(', ', map { $_->{ip} } @{$res->{peers}});
});

DESCRIPTION

Net::BitTorrent::Tracker::UDP implements the lightweight UDP Tracker Protocol (BEP 15). UDP is the preferred transport for BitTorrent trackers as it significantly reduces overhead on the tracker server compared to HTTP.

BitTorrent v2 Support

This module is BEP 52 compliant. It correctly handles 32-byte SHA-256 infohashes in both announce and scrape packets by dynamically adjusting the binary structure of the outgoing messages.

METHODS

perform_announce( \%params, [$callback] )

Synchronously executes the UDP announce cycle:

1. Sends a connect request to get a session connection_id.
2. Sends the announce request containing client stats and infohash.
3. Parses the response into a hashref of swarm data and peers.

perform_scrape( \@infohashes, [$callback] )

Synchronously fetches seeder/leecher counts for multiple torrents.

url( )

Returns the tracker URL.

Specifications

  • BEP 15: UDP Tracker Protocol

  • BEP 52: The BitTorrent Protocol v2 (UDP extensions)

AUTHOR

Sanko Robinson <sanko@cpan.org>

COPYRIGHT

Copyright (C) 2008-2026 by Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.