AnyEvent-BitTorrent
view release on metacpan or search on metacpan
This is the preferred port local host binds and expects incoming peers to
connect to.
By default, this is a zero; the system will pick a port number randomly.
- `on_hash_fail`
This is a subroutine called whenever a piece fails to pass
[hashcheck](#hashcheck). The callback is handed the piece's index.
- `on_hash_pass`
This is a subroutine called whenever a piece passes its
[hashcheck](#hashcheck). The callback is handed the piece's index.
- `state`
This must be one of the following:
- `started`
This is the default. The client will attempt to create new connections, make
and fill requests, etc. This is normal client behavior.
- `paused`
In this state, connections will be made and accepted but no piece requests
will be made or filled. To resume full, normal behavior, you must call
[`start( )`](#start).
- `stopped`
Everything is put on hold. No new outgoing connections are attempted and
incoming connections are rejected. To resume full, normal behavior, you must
call [`start( )`](#start).
- `piece_cache`
This is the index list returned by [`piece_cache( )`](#piece_cache) in a
previous instance. Using this should make a complete resume system a trivial
task.
## `hashcheck( [...] )`
This method expects...
- ...a list of integers. You could use this to check a range of pieces (a
single file, for example).
$client->hashcheck( 1 .. 5, 34 .. 56 );
- ...a single integer. Only that specific piece is checked.
$client->hashcheck( 17 );
- ...nothing. All data related to this torrent will be checked.
$client->hashcheck( );
As pieces pass or fail, your `on_hash_pass` and `on_hash_fail` callbacks are
triggered.
## `start( )`
Sends a 'started' event to trackers and starts performing as a client is
expected. New connections are made and accepted, requests are made and filled,
etc.
## `stop( )`
Sends a stopped event to trackers, closes all connections, stops attempting
new outgoing connections, rejects incoming connections and closes all open
files.
## `pause( )`
The client remains mostly active; new connections will be made and accepted,
etc. but no requests will be made or filled while the client is paused.
## `infohash( )`
Returns the 20-byte SHA1 hash of the value of the info key from the metadata
file.
## `peerid( )`
Returns the 20 byte string used to identify the client. Please see the
[spec](#peerid-specification) below.
## `port( )`
Returns the port number the client is listening on.
## `size( )`
Returns the total size of all [files](#files) described in the torrent's
metadata.
## `name( )`
Returns the UTF-8 encoded string the metadata suggests we save the file (or
directory, in the case of multi-file torrents) under.
## `uploaded( )`
Returns the total amount uploaded to remote peers.
## `downloaded( )`
Returns the total amount downloaded from other peers.
## `left( )`
Returns the approximate amount based on the pieces we still
[want](#wanted) multiplied by the [size of pieces](#piece_length).
## `piece_length( )`
Returns the number of bytes in each piece the file or files are split into.
For the purposes of transfer, files are split into fixed-size pieces which are
( run in 0.572 second using v1.01-cache-2.11-cpan-39bf76dae61 )