From 81bf8763f6d844fd5cb4b2806d6bfe3988665fbe Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 17 Oct 2008 03:23:30 +0000 Subject: [PATCH] regenerated documentation. added makefile for docs, added rst template file --- docs/building.html | 141 ++-- docs/client_test.html | 33 + docs/dht_extensions.html | 47 +- docs/examples.html | 65 +- docs/extension_protocol.html | 49 +- docs/features.html | 79 +- docs/index.html | 33 + docs/libtorrent_plugins.html | 112 ++- docs/makefile | 30 + docs/manual.html | 1423 +++++++++++++++++--------------- docs/projects.html | 33 + docs/template.txt | 41 + docs/udp_tracker_protocol.html | 113 ++- 13 files changed, 1338 insertions(+), 861 deletions(-) create mode 100644 docs/makefile create mode 100644 docs/template.txt diff --git a/docs/building.html b/docs/building.html index 080b7bd7d..dda9c40e4 100644 --- a/docs/building.html +++ b/docs/building.html @@ -3,54 +3,76 @@ - + libtorrent manual + + +
+
+
+ +
+ +

libtorrent manual

- +
Author:Arvid Norberg, arvid@rasterbar.com
Arvid Norberg, arvid@rasterbar.com
-
-

downloading and building

+
+

downloading and building

To acquire the latest version of libtorrent, you'll have to grab it from SVN. -You'll find instructions on how to do this here (see subversion access).

+You'll find instructions on how to do this here (see subversion access).

The build systems supported "out of the box" in libtorrent are boost-build v2 (BBv2) and autotools (for unix-like systems). If you still can't build after following these instructions, you can usually get help in the #libtorrent IRC channel on irc.freenode.net.

-

Community contributed build tutorials can be found on the wiki.

-
-

building from svn

+

Community contributed build tutorials can be found on the wiki.

+
+

building from svn

To build libtorrent from svn you need to check out the libtorrent sources from sourceforge and also check out the asio sources from its sourceforge cvs. If you downloaded a release tarball, you can skip this section.

To prepare the directory structure for building, follow these steps:

    -
  • Check out libtorrent (instructions).
  • -
  • Check out asio (instructions).
  • +
  • Check out libtorrent (instructions).
  • +
  • Check out asio (instructions).
  • Copy the asio/include/asio/ directory into the libtorrent/include/libtorrent/ directory. Alternatively you can make a symbolic link.
  • Copy asio/include/asio.hpp into libtorrent/include/libtorrent.
  • @@ -58,11 +80,11 @@ directory. Alternatively you can make a symbolic link.

    Now the libtorrent directory is ready for building. Follow the steps in one of the following sections depending on which build system you prefer to use.

-
-

building with BBv2

+
+

building with BBv2

The primary reason to use boost-build is that it will automatically build the dependent boost libraries with the correct compiler settings, in order to -ensure that the build targets are link compatible (see boost guidelines +ensure that the build targets are link compatible (see boost guidelines for some details on this issue).

Since BBv2 will build the boost libraries for you, you need the full boost source package. Having boost installed via some package system is usually not @@ -70,17 +92,17 @@ enough (and even if it is enough, the necessary environment variables are usually not set by the package installer).

If you want to build against an installed copy of boost, you can skip directly to step 3 (assuming you also have boost build installed).

-
-

Step 1: Download boost

-

You'll find boost here.

+
+

Step 1: Download boost

+

You'll find boost here.

Extract the archive to some directory where you want it. For the sake of this guide, let's assume you extract the package to c:\boost_1_34_0 (I'm using a windows path in this example since if you're on linux/unix you're more likely to use the autotools). You'll need at least version 1.34 of the boost library in order to build libtorrent.

-
-

Step 2: Setup BBv2

+
+

Step 2: Setup BBv2

First you need to build bjam. You do this by opening a terminal (In windows, run cmd). Change directory to c:\boost_1_34_0\tools\jam\src. Then run the script called @@ -130,10 +152,10 @@ using darwin : 3.3 : g++-3.3 ; using darwin : 4.0 : g++-4.0 ;

Note that the spaces around the semi-colons and colons are important!

-

Also see the official installation instructions.

+

Also see the official installation instructions.

-
-

Step 3: Building libtorrent

+
+

Step 3: Building libtorrent

When building libtorrent, the Jamfile expects the environment variable BOOST_ROOT to be set to the boost installation directory. It uses this to find the boost libraries it depends on, so they can be built and their headers @@ -195,7 +217,7 @@ Also, make sure the paths are correct in the different environments. In cygwin, /cygdrive/c/boost_1_34_0). In the windows environment, they should have the typical windows format (c:/boost_1_34_0).

The Jamfile will define NDEBUG when it's building a release build. -For more build configuration flags see Build configurations.

+For more build configuration flags see Build configurations.

Build features:

@@ -270,10 +292,10 @@ with the libtorrent package. definitely help to define NDEBUG, since it will remove the invariant checks within the library.

-
-

building openssl for windows

+
+

building openssl for windows

To build openssl for windows with Visual Studio 7.1 (2003) execute the following commands in a command shell:

@@ -694,6 +716,17 @@ copy out32\ssleay32.lib "C:\Program Files\Microsoft Visual Studio .NET 2003
 be picked up by libtorrent.

+ + + + + diff --git a/docs/client_test.html b/docs/client_test.html index 89cde74fe..16747bf34 100644 --- a/docs/client_test.html +++ b/docs/client_test.html @@ -5,10 +5,32 @@ client_test example program + + +
+
+
+ +
+ +

client_test example program

Client test is a, more or less, complete bittorrent client. It lacks most @@ -50,6 +72,17 @@ instead of dowloading parts of pieces. It may make it easier to determine which peer that sent the corrupt data if a piece fails the hash test.

unicode_support.png

There's unicode support on linux, MacOS X and Windows.

+
+ +
+ +
diff --git a/docs/dht_extensions.html b/docs/dht_extensions.html index 4fda3f42f..65080900b 100644 --- a/docs/dht_extensions.html +++ b/docs/dht_extensions.html @@ -6,24 +6,46 @@ + + +
+
+
+ +
+ +
geoip
  • off - geo ip lookups disabled
  • -
  • static - MaxMind geo ip lookup code linked +
  • static - MaxMind geo ip lookup code linked in statically. Note that this code is under LGPL license.
  • -
  • shared - The MaxMind geo ip lookup library +
  • shared - The MaxMind geo ip lookup library is expected to be installed on the system and it will be used.
@@ -395,12 +417,12 @@ the name of the feature, just the value.

When building the example client on windows, you need to build with link=static otherwise you may get unresolved external symbols for some boost.program-options symbols.

-

For more information, see the Boost build v2 documentation, or more -specifically the section on builtin features.

+

For more information, see the Boost build v2 documentation, or more +specifically the section on builtin features.

-
-

building with autotools

+
+

building with autotools

First of all, you need to install automake and autoconf. Many unix/linux systems comes with these preinstalled.

The prerequisites for building libtorrent are boost.thread, boost.date_time @@ -411,11 +433,11 @@ boost.integer, boost.iterator, boost.tuple, boost.array, boost.function, boost.smart_ptr, boost.preprocessor, boost.static_assert.

If you want to build the client_test example, you'll also need boost.regex and boost.program_options.

-
-

Step 1: Generating the build system

+
+

Step 1: Generating the build system

No build system is present if libtorrent is checked out from CVS - it needs to be generated first. If you're building from a released tarball, -you may skip directly to Step 2: Running configure.

+you may skip directly to Step 2: Running configure.

Execute the following commands, in the given order, to generate the build system:

@@ -427,8 +449,8 @@ autoconf
 

On darwin/OSX you have to run glibtoolize instead of libtoolize.

-
-

Step 2: Running configure

+
+

Step 2: Running configure

In your shell, change directory to the libtorrent directory and run ./configure. This will look for libraries and C++ features that libtorrent is dependent on. If something is missing or can't be found it will print an @@ -476,8 +498,8 @@ checking for main in -lboost_thread... yes directory contains spaces. Make sure you either rename the directories with spaces in their names to remove the spaces or move the libtorrent directory.

-
-

Creating a debug build

+
+

Creating a debug build

To tell configure to build a debug version (with debug info, asserts and invariant checks enabled), you have to run the configure script with the following option:

@@ -485,8 +507,8 @@ with the following option:

./configure --enable-debug=yes
-
-

Creating a release build

+
+

Creating a release build

To tell the configure to build a release version (without debug info, asserts and invariant checks), you have to run the configure script with the following option:

@@ -495,8 +517,8 @@ with the following option:

The above option make use of -DNDEBUG, which is used throughout libtorrent.

-
-

Step 3: Building libtorrent

+
+

Step 3: Building libtorrent

Once the configure script is run successfully, you just type make and libtorrent, the examples and the tests will be built.

When libtorrent is built it may be a good idea to run the tests, you do this @@ -510,8 +532,8 @@ make

-
-

building with other build systems

+
+

building with other build systems

If you're making your own project file, note that there are two versions of the file abstraction. There's one file_win.cpp which relies on windows file API that supports files larger than 2 Gigabytes. This does not work in @@ -524,10 +546,10 @@ filenames, so if your target is Windows 2000 and up, you may want to use

If you're building in MS Visual Studio, you may have to set the compiler options "force conformance in for loop scope", "treat wchar_t as built-in type" and "Enable Run-Time Type Info" to Yes. For a detailed description -on how to build libtorrent with VS, see the wiki.

+on how to build libtorrent with VS, see the wiki.

-
-

build configurations

+
+

build configurations

By default libtorrent is built In debug mode, and will have pretty expensive invariant checks and asserts built into it. If you want to disable such checks (you want to do that in a release build) you can see the table below for which @@ -677,8 +699,8 @@ the header files and cpp files.

- +
Author:Arvid Norberg, arvid@rasterbar.com
Arvid Norberg, arvid@rasterbar.com
-
-

Mainline DHT extensions

+
+

Mainline DHT extensions

libtorrent implements a few extensions to the Mainline DHT protocol.

-
-

client identification

+
+

client identification

In each DHT packet, an extra key is inserted named "v". This is a string describing the client and version used. This can help alot when debugging and finding errors in client implementations. The string is encoded as four @@ -51,8 +73,8 @@ as a binary number describing the client version.

-
-

IPv6 support

+
+

IPv6 support

The DHT messages that don't support IPv6 are the nodes replies. They encode all the contacts as 6 bytes packed together in sequence in a string. The problem is that IPv6 endpoints cannot be encoded as 6 bytes, but @@ -66,6 +88,17 @@ and 18 bytes in IPv6 case).

only IPv4 nodes present.

+
+ +
+ +
diff --git a/docs/examples.html b/docs/examples.html index 682f282d5..cdb21b3ff 100644 --- a/docs/examples.html +++ b/docs/examples.html @@ -3,41 +3,63 @@ - + libtorrent Examples + + +
+
+
+ +
+ +

libtorrent Examples

- +
Author:Arvid Norberg, arvid@rasterbar.com
Arvid Norberg, arvid@rasterbar.com
-
-

examples

+
+

examples

Except for the example programs in this manual, there's also a bigger example of a (little bit) more complete client, client_test. There are separate -instructions for how to use it here if you'd like to try it. Note that building +instructions for how to use it here if you'd like to try it. Note that building client_test also requires boost.regex and boost.program_options library.

-
-

dump_torrent

+
+

dump_torrent

This is an example of a program that will take a torrent-file as a parameter and print information about it to std out:

@@ -140,8 +162,8 @@ int main(int argc, char* argv[])
 }
 
-
-

simple client

+
+

simple client

This is a simple client. It doesn't have much output to keep it simple:

 int main(int argc, char* argv[])
@@ -185,8 +207,8 @@ if (argc != 2)
 }
 
-
-

make_torrent

+
+

make_torrent

Shows how to create a torrent from a directory tree:

 #include <iostream>
@@ -277,6 +299,17 @@ int main(int argc, char* argv[])
 
+
+ +
+ +
diff --git a/docs/extension_protocol.html b/docs/extension_protocol.html index 3ead11ba8..50fd03883 100644 --- a/docs/extension_protocol.html +++ b/docs/extension_protocol.html @@ -6,22 +6,44 @@ + + +
+
+
+ +
+ +
- +
Author:Arvid Norberg, arvid@rasterbar.com -Ludvig Strigeus, ludde@utorrent.com
Arvid Norberg, arvid@rasterbar.com +Ludvig Strigeus, ludde@utorrent.com
-
-

extension protocol for bittorrent

+
+

extension protocol for bittorrent

The intention of this protocol is to provide a simple and thin transport for extensions to the bittorrent protocol. Supporting this protocol makes it easy to add new extensions without interfering with the standard @@ -81,8 +103,8 @@ message as specified by the handshake. -

-

handshake message

+
+

handshake message

The payload of the handshake message is a bencoded dictionary. All items in the dictionary are optional. Any unknown names should be ignored by the client. All parts of the dictionary are case sensitive. @@ -233,8 +255,8 @@ for the actual extensions to the bittorrent protocol and the extensions named in the example above (such as p) are just examples of possible extensions.

-
-

rationale

+
+

rationale

The reason why the extension messages' IDs would be defined in the handshake is to avoid having a global registry of message IDs. Instead the names of the extension messages requires unique names, which is much easier to do without @@ -265,6 +287,17 @@ protocol more readable for a human, but the BT protocol wasn't designed to be a human readable protocol, so why bother.

+
+ +
+ +
diff --git a/docs/features.html b/docs/features.html index 1e1dd486c..f47f1b7b4 100644 --- a/docs/features.html +++ b/docs/features.html @@ -6,30 +6,52 @@ libtorrent manual + + +
+
+
+ +
+ +

libtorrent manual

- +
Author:Arvid Norberg, arvid@rasterbar.com
Arvid Norberg, arvid@rasterbar.com
-
-

introduction

+
+

introduction

libtorrent is a C++ library that aims to be a good alternative to all the other bittorrent implementations around. It is a library and not a full featured client, although it comes with a working @@ -41,33 +63,33 @@ example client.

  • to be very easy to use
  • -
    -

    features

    +
    +

    features

    libtorrent is still being developed, however it is stable. It is an ongoing project (including this documentation). The current state includes the following features:

    • trackerless torrents (using the Mainline kademlia DHT protocol) with -some DHT extensions.
    • +some DHT extensions.
    • support for IPv6
    • NAT-PMP and UPnP support (automatic port mapping on routers that supports it)
    • piece-wise, unordered, incremental file allocation
    • uses separate threads for checking files and for main downloader, with a fool-proof thread-safe library interface. (i.e. There's no way for the -user to cause a deadlock). (see threads)
    • +user to cause a deadlock). (see threads)
    • adjusts the length of the request queue depending on download rate.
    • -
    • multitracker extension support (as specified by John Hoffman)
    • +
    • multitracker extension support (as specified by John Hoffman)
    • supports files > 2 gigabytes.
    • serves multiple torrents on a single port and in a single thread
    • fast resume support, a way to get rid of the costly piece check at the start of a resumed torrent. Saves the storage state, piece_picker state as well as all local peers in a separate fast-resume file.
    • -
    • HTTP seeding, as specified by Michael Burford of GetRight.
    • +
    • HTTP seeding, as specified by Michael Burford of GetRight.
    • piece picking on block-level (as opposed to piece-level). This means it can download parts of the same piece from different peers. It will also prefer to download whole pieces from single peers if the download speed is high enough from that particular peer.
    • -
    • supports the udp-tracker protocol by Olaf van der Spek.
    • +
    • supports the udp-tracker protocol by Olaf van der Spek.
    • queues torrents for file check, instead of checking all of them in parallel.
    • supports http proxies and basic proxy authentication
    • gzipped tracker-responses
    • @@ -76,7 +98,7 @@ unchoked peers
    • implements fair trade. User settable trade-ratio, must at least be 1:1, but one can choose to trade 1 for 2 or any other ratio that isn't unfair to the other party.
    • -
    • supports an extension protocol. See extensions.
    • +
    • supports an extension protocol. See extensions.
    • supports the no_peer_id=1 extension that will ease the load off trackers.
    • possibility to limit the number of connections.
    • delays have messages if there's no other outgoing traffic to the peer, and @@ -91,11 +113,11 @@ want to download.
    • being connected
    -
    -

    portability

    +
    +

    portability

    libtorrent is portable at least among Windows, MacOS X and other UNIX-systems. It uses Boost.Thread, Boost.Filesystem, Boost.Date_time and various other -boost libraries as well as zlib (shipped) and asio (shipped). At least version +boost libraries as well as zlib (shipped) and asio (shipped). At least version 1.33.1 of boost is required.

    Since libtorrent uses asio, it will take full advantage of high performance network APIs on the most popular platforms. I/O completion ports on windows, @@ -114,15 +136,26 @@ epoll on linux and kqueue on MacOS X and BSD.

  • msvc6
  • -
    -

    license

    -

    libtorrent is released under the BSD-license.

    +
    +

    license

    +

    libtorrent is released under the BSD-license.

    This means that you can use the library in your project without having to release its source code. The only requirement is that you give credit to the author of the library by including the libtorrent license in your software or documentation.

    -

    Here's a list of some projects that uses libtorrent.

    +

    Here's a list of some projects that uses libtorrent.

    +
    + +
    + +
    diff --git a/docs/index.html b/docs/index.html index 181215b53..616b803fd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,10 +5,32 @@ + + +
    +
    +
    + +
    + +
      @@ -85,6 +107,17 @@ library and not a full featured client, although it comes with a working

      sf_logo

    +
    + +
    + +
    diff --git a/docs/libtorrent_plugins.html b/docs/libtorrent_plugins.html index b364860e9..37c53c7a3 100644 --- a/docs/libtorrent_plugins.html +++ b/docs/libtorrent_plugins.html @@ -3,41 +3,64 @@ - + + + +
    +
    +
    + +
    + +
    + - +
    Author:Arvid Norberg, arvid@rasterbar.com
    Arvid Norberg, arvid@rasterbar.com
    -
    -

    libtorrent plugins

    -
    -

    Contents

    +
    +

    libtorrent plugins

    +

    libtorrent has a plugin interface for implementing extensions to the protocol. @@ -47,13 +70,13 @@ to fit a particular (closed) network.

    In short, the plugin interface makes it possible to:

    • register extension messages (sent in the extension handshake), see -extensions.
    • +extensions.
    • add data and parse data from the extension handshake.
    • send extension messages and standard bittorrent messages.
    • override or block the handling of standard bittorrent messages.
    -
    -

    a word of caution

    +
    +

    a word of caution

    Writing your own plugin is a very easy way to introduce serious bugs such as dead locks and race conditions. Since a plugin has access to internal structures it is also quite easy to sabotage libtorrent's operation.

    @@ -64,12 +87,12 @@ thread, you cannot use any of the member functions on the internal structures in libtorrent, since those require the mutex to be locked. Futhermore, you would also need to have a mutex on your own shared data within the plugin, to make sure it is not accessed at the same time from the libtorrent thread (through a -callback). See boost thread's mutex. If you need to send out a message from +callback). See boost thread's mutex. If you need to send out a message from another thread, use an internal queue, and do the actual sending in tick().

    -
    -

    plugin interface

    +
    +

    plugin interface

    The plugin interface consists of two base classes that the plugin may implement. These are called torrent_plugin and peer_plugin. They are both found in the <libtorrent/extensions.hpp> header.

    @@ -92,8 +115,8 @@ for this torrent. If it is a valid pointer (to a class inheriting torrent_plugin), it will be associated with this torrent and callbacks will be made on torrent events.

    -
    -

    torrent_plugin

    +
    +

    torrent_plugin

    The synopsis for torrent_plugin follows:

     struct torrent_plugin
    @@ -115,8 +138,8 @@ struct torrent_plugin
     

    This is the base class for a torrent_plugin. Your derived class is (if added as an extension) instantiated for each torrent in the session. The callback hook functions are defined as follows.

    -
    -

    new_connection()

    +
    +

    new_connection()

     boost::shared_ptr<peer_plugin> new_connection(peer_connection*);
     
    @@ -133,8 +156,8 @@ held by the torrent object. So, it is generally a good idea to not keep a use weak_ptr.

    If this function throws an exception, the connection will be closed.

    -
    -

    on_piece_pass() on_piece_fail()

    +
    +

    on_piece_pass() on_piece_fail()

     void on_piece_pass(int index);
     void on_piece_failed(int index);
    @@ -144,16 +167,16 @@ check, respectively. The indextorrent and the piece_picker.

    -
    -

    tick()

    +
    +

    tick()

     void tick();
     

    This hook is called approximately once per second. It is a way of making it easy for plugins to do timed events, for sending messages or whatever.

    -
    -

    on_pause() on_resume()

    +
    +

    on_pause() on_resume()

     bool on_pause();
     bool on_resume();
    @@ -169,8 +192,8 @@ handler it will recurse back into your handler, so in order to invoke the
     standard handler, you have to keep your own state on whether you want standard
     behavior or overridden behavior.

    -
    -

    on_files_checked()

    +
    +

    on_files_checked()

     void on_files_checked();
     
    @@ -180,8 +203,8 @@ checked. If there are no files to check, this function is called immediately.

    -
    -

    peer_plugin

    +
    +

    peer_plugin

     struct peer_plugin
     {
    @@ -218,8 +241,8 @@ struct peer_plugin
     };
     
    -
    -

    disk_buffer_holder

    +
    +

    disk_buffer_holder

     struct disk_buffer_holder
     {
    @@ -236,6 +259,17 @@ buffer and transferres ownership and responsibility to free it to the caller.

    buffer() returns the pointer without transferring responsibility. If this buffer has been released, buffer() will return 0.

    +
    + +
    + +
    diff --git a/docs/makefile b/docs/makefile new file mode 100644 index 000000000..358997d9c --- /dev/null +++ b/docs/makefile @@ -0,0 +1,30 @@ +WEB_PATH = ~/Documents/rasterbar/web/products/libtorrent +DOCUTILS = ~/docutils + +TARGETS = index.html \ + udp_tracker_protocol.html \ + projects.html \ + client_test.html \ + manual.html \ + building.html \ + features.html \ + examples.html \ + extension_protocol.html \ + dht_extensions.html \ + libtorrent_plugins.html + +all: $(TARGETS) + +%.pdf:%.tex + texexec --pdf $? + +%.tex:%.rst + $(DOCUTILS)/tools/rst2context.py $? $@ + +%.html:%.rst + python $(DOCUTILS)/tools/rst2html.py --template=template.txt --stylesheet-path=style.css --link-stylesheet --no-toc-backlinks $? > $@ + cp $@ $(WEB_PATH)/$@ + +clean: + rm -f $(TARGETS) round_trip_distribution.log + diff --git a/docs/manual.html b/docs/manual.html index cd7d3f946..3bee2c8f7 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -3,271 +3,293 @@ - + libtorrent API Documentation + + +
    +
    +
    + +
    + +

    libtorrent API Documentation

    - +
    Author:Arvid Norberg, arvid@rasterbar.com
    Arvid Norberg, arvid@rasterbar.com
    Version: 0.13
    -

    Table of contents

    +

    Table of contents

    -
    -

    overview

    +
    +

    overview

    The interface of libtorrent consists of a few classes. The main class is the session, it contains the main loop that serves all torrents.

    The basic usage is as follows:

    Each class and function is described in this manual.

    -

    For a description on how to create torrent files, see make_torrent.

    +

    For a description on how to create torrent files, see make_torrent.

    -
    -

    network primitives

    +
    +

    network primitives

    There are a few typedefs in the libtorrent namespace which pulls in network types from the asio namespace. These are:

    @@ -285,10 +307,10 @@ udp::endpoint
     

    Which are the endpoint types used in libtorrent. An endpoint is an address with an associated port.

    -

    For documentation on these types, please refer to the asio documentation.

    +

    For documentation on these types, please refer to the asio documentation.

    -
    -

    session

    +
    +

    session

    The session class has the following synopsis:

     class session: public boost::noncopyable
    @@ -373,6 +395,7 @@ class session: public boost::noncopyable
             std::auto_ptr<alert> pop_alert();
             alert const* wait_for_alert(time_duration max_wait);
             void set_alert_mask(int m);
    +        size_t set_alert_queue_size_limit(size_t queue_size_limit_);
     
             void add_extension(boost::function<
                     boost::shared_ptr<torrent_plugin>(torrent*)> ext);
    @@ -399,8 +422,8 @@ class session: public boost::noncopyable
     

    Once it's created, the session object will spawn the main thread that will do all the work. The main thread will be idle as long it doesn't have any torrents to participate in.

    -
    -

    session()

    +
    +

    session()

     session(fingerprint const& print
    @@ -416,7 +439,7 @@ session(fingerprint const& print
     

    If the fingerprint in the first overload is omited, the client will get a default fingerprint stating the version of libtorrent. The fingerprint is a short string that will be used in the peer-id to identify the client and the client's version. For more details see the -fingerprint class. The constructor that only takes a fingerprint will not open a +fingerprint class. The constructor that only takes a fingerprint will not open a listen port for the session, to get it running you'll have to call session::listen_on(). The other constructor, that takes a port range and an interface as well as the fingerprint will automatically try to listen on a port on the given interface. For more information about @@ -425,16 +448,16 @@ the parameters, see listen_on()

    -
    -

    ~session()

    +
    +

    ~session()

    The destructor of session will notify all trackers that our torrents have been shut down. If some trackers are down, they will time out. All this before the destructor of session returns. So, it's advised that any kind of interface (such as windows) are closed before destructing the session object. Because it can take a few second for it to finish. The timeout can be set with set_settings().

    -
    -

    pause() resume() is_paused()

    +
    +

    pause() resume() is_paused()

    ::
    @@ -448,8 +471,8 @@ will restore the torrents to their previous paused state. i.e. the session pause state is separate from the torrent pause state. A torrent is inactive if it is paused or if the session is paused.

    -
    -

    abort()

    +
    +

    abort()

     session_proxy abort();
    @@ -473,8 +496,8 @@ public:
     };
     
    -
    -

    add_torrent()

    +
    +

    add_torrent()

     typedef storage_interface* (&storage_constructor_type)(
    @@ -517,12 +540,12 @@ the torrent as long as it doesn't have metadata. See add_torrent() will throw
    -duplicate_torrent which derives from std::exception unless duplicate_is_error
    +duplicate_torrent which derives from std::exception unless duplicate_is_error
     is set to false. In that case, add_torrent will return the handle to the existing
     torrent.

    The optional parameter, resume_data can be given if up to date fast-resume data is available. The fast-resume data can be acquired from a running torrent by calling -save_resume_data() on torrent_handle. See fast resume. The vector that is +save_resume_data() on torrent_handle. See fast resume. The vector that is passed in will be swapped into the running torrent instance with std::vector::swap().

    The storage_mode parameter refers to the layout of the storage for this torrent. There are 3 different modes:

    @@ -539,7 +562,7 @@ filesystems that don't support sparse files. are rearranged to finally be in their correct places once the entire torrent has been downloaded. -

    For more information, see storage allocation.

    +

    For more information, see storage allocation.

    paused is a boolean that specifies whether or not the torrent is to be started in a paused state. I.e. it won't connect to the tracker or any of the peers until it's resumed. This is typically a good way of avoiding race conditions when setting @@ -547,19 +570,19 @@ configuration options on torrents before starting them.

    If auto_managed is true, this torrent will be queued, started and seeded automatically by libtorrent. When this is set, the torrent should also be started as paused. The default queue order is the order the torrents were added. They -are all downloaded in that order. For more details, see queuing.

    +are all downloaded in that order. For more details, see queuing.

    storage can be used to customize how the data is stored. The default storage will simply write the data to the files it belongs to, but it could be overridden to save everything to a single file at a specific location or encrypt the content on disk for instance. For more information about the storage_interface -that needs to be implemented for a custom storage, see storage_interface.

    +that needs to be implemented for a custom storage, see storage_interface.

    The userdata parameter is optional and will be passed on to the extension -constructor functions, if any (see add_extension()).

    -

    The torrent_handle returned by add_torrent() can be used to retrieve information +constructor functions, if any (see add_extension()).

    +

    The torrent_handle returned by add_torrent() can be used to retrieve information about the torrent's progress, its peers etc. It is also used to abort a torrent.

    -
    -

    remove_torrent()

    +
    +

    remove_torrent()

     void remove_torrent(torrent_handle const& h, int options = none);
    @@ -570,10 +593,10 @@ the tracker that we've stopped participating in the swarm. The optional second a
     options can be used to delete all the files downloaded by this torrent. To do this, pass
     in the value session::delete_files. The removal of the torrent is asyncronous, there is
     no guarantee that adding the same torrent immediately after it was removed will not throw
    -a duplicate_torrent exception.

    +a duplicate_torrent exception.

    -
    -

    find_torrent() get_torrents()

    +
    +

    find_torrent() get_torrents()

     torrent_handle find_torrent(sha_hash const& ih);
    @@ -587,8 +610,8 @@ In case the torrent cannot be found, an invalid torrent_handle is returned.

    get_torrents() returns a vector of torrent_handles to all the torrents currently in the session.

    -
    -

    set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()

    +
    +

    set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()

     void set_upload_rate_limit(int bytes_per_second);
    @@ -605,8 +628,8 @@ of upload rate.
     download_rate_limit() and upload_rate_limit() returns the previously
     set limits.

    -
    -

    set_max_uploads() set_max_connections()

    +
    +

    set_max_uploads() set_max_connections()

     void set_max_uploads(int limit);
    @@ -619,8 +642,8 @@ minimum of at least two connections per torrent, so if you set a too low
     connections limit, and open too many torrents, the limit will not be met. The
     number of uploads is at least one per torrent.

    -
    -

    num_uploads() num_connections()

    +
    +

    num_uploads() num_connections()

     int num_uploads() const;
    @@ -630,8 +653,8 @@ int num_connections() const;
     

    Returns the number of currently unchoked peers and the number of connections (including half-open ones) respectively.

    -
    -

    set_max_half_open_connections() max_half_open_connections()

    +
    +

    set_max_half_open_connections() max_half_open_connections()

     void set_max_half_open_connections(int limit);
    @@ -650,8 +673,8 @@ their turn to get connected.

    max_half_open_connections() returns the set limit. This limit defaults to 8 on windows.

    -
    -

    load_asnum_db() load_country_db() int as_for_ip()

    +
    +

    load_asnum_db() load_country_db() int as_for_ip()

     bool load_asnum_db(char const* file);
    @@ -660,13 +683,13 @@ int as_for_ip(address const& adr);
     

    These functions are not available if TORRENT_DISABLE_GEO_IP is defined. They -expects a path to the MaxMind ASN database and MaxMind GeoIP database +expects a path to the MaxMind ASN database and MaxMind GeoIP database respectively. This will be used to look up which AS and country peers belong to.

    as_for_ip returns the AS number for the IP address specified. If the IP is not in the database or the ASN database is not loaded, 0 is returned.

    -
    -

    load_state() state()

    +
    +

    load_state() state()

     void load_state(entry const& ses_state);
    @@ -677,8 +700,8 @@ entry state() const;
     that's stored is peak download rates for ASes. This map is used to
     determine which order to connect to peers.

    -
    -

    set_ip_filter()

    +
    +

    set_ip_filter()

     void set_ip_filter(ip_filter const& filter);
    @@ -687,12 +710,12 @@ void set_ip_filter(ip_filter const& filter);
     

    Sets a filter that will be used to reject and accept incoming as well as outgoing connections based on their originating ip address. The default filter will allow connections to any ip address. To build a set of rules for which addresses are -accepted and not, see ip_filter.

    -

    Each time a peer is blocked because of the IP filter, a peer_blocked_alert is +accepted and not, see ip_filter.

    +

    Each time a peer is blocked because of the IP filter, a peer_blocked_alert is generated.

    -
    -

    status()

    +
    +

    status()

     session_status status() const;
    @@ -734,6 +757,11 @@ struct session_status
             size_type total_dht_download;
             size_type total_dht_upload;
     
    +        float tracker_upload_rate;
    +        float tracker_download_rate;
    +        size_type total_tracker_download;
    +        size_type total_tracker_upload;
    +
             size_type total_redundant_bytes;
             size_type total_failed_bytes;
     
    @@ -790,8 +818,8 @@ becomes unresponsive.

    network.

    active_requests is a vector of the currently running DHT lookups.

    -
    -

    get_cache_status()

    +
    +

    get_cache_status()

     cache_status get_cache_status() const;
    @@ -828,8 +856,8 @@ for the read cache.

    This includes both read and write cache.

    read_cache_size is the number of 16KiB blocks in the read cache.

    -
    -

    get_cache_info()

    +
    +

    get_cache_info()

     void get_cache_info(sha1_hash const& ih
    @@ -858,8 +886,8 @@ the data for that block being in the disk cache and 
     

    kind specifies if this piece is part of the read cache or the write cache.

    -
    -

    is_listening() listen_port() listen_on()

    +
    +

    is_listening() listen_port() listen_on()

     bool is_listening() const;
    @@ -883,7 +911,7 @@ the range and so on. The interface parameter can be left as 0, in that case the
     os will decide which interface to listen on, otherwise it should be the ip-address
     of the interface you want the listener socket bound to. listen_on() returns true
     if it managed to open the socket, and false if it failed. If it fails, it will also
    -generate an appropriate alert (listen_failed_alert).

    +generate an appropriate alert (listen_failed_alert).

    The interface parameter can also be a hostname that will resolve to the device you want to listen on.

    If you're also starting the DHT, it is a good idea to do that after you've called @@ -902,18 +930,19 @@ with a DHT ping packet, and connect to those that responds first. On windows one can only connect to a few peers at a time because of a built in limitation (in XP Service pack 2).

    -
    -

    pop_alert() set_alert_mask() wait_for_alert()

    +
    +

    pop_alert() set_alert_mask() wait_for_alert() set_alert_queue_size_limit()

     std::auto_ptr<alert> pop_alert();
     alert const* wait_for_alert(time_duration max_wait);
     void set_alert_mask(int m);
    +size_t set_alert_queue_size_limit(size_t queue_size_limit_);
     

    pop_alert() is used to ask the session if any errors or events has occurred. With set_alert_mask() you can filter which alerts to receive through pop_alert(). -For information about the alert categories, see alerts.

    +For information about the alert categories, see alerts.

    wait_for_alert blocks until an alert is available, or for no more than max_wait time. If wait_for_alert returns because of the time-out, and no alerts are available, it returns 0. If at least one alert was generated, a pointer to that alert is returned. @@ -921,9 +950,12 @@ The alert is not popped, any subsequent calls to pop_alert. This is useful for leaving any alert dispatching mechanism independent of this blocking call, the dispatcher can be called and it can pop the alert independently.

    +

    set_alert_queue_size_limit() you can specify how many alerts can be awaiting for dispatching. +If this limit is reached, new incoming alerts can not be received until alerts are popped +by calling pop_alert. Default value is 1000.

    -
    -

    add_extension()

    +
    +

    add_extension()

     void add_extension(boost::function<
    @@ -933,7 +965,7 @@ void add_extension(boost::function<
     

    This function adds an extension to this session. The argument is a function object that is called with a torrent* and which should return a boost::shared_ptr<torrent_plugin>. To write custom plugins, see -libtorrent plugins. For the typical bittorrent client all of these +libtorrent plugins. For the typical bittorrent client all of these extensions should be added. The main plugins implemented in libtorrent are:

    metadata extension
    @@ -972,8 +1004,8 @@ eliminate most problems on poisoned torrents. ses.add_extension(&libtorrent::create_smart_ban_plugin);
    -
    -

    set_settings() set_pe_settings()

    +
    +

    set_settings() set_pe_settings()

     void set_settings(session_settings const& settings);
    @@ -981,11 +1013,11 @@ void set_pe_settings(pe_settings const& settings);
     

    Sets the session settings and the packet encryption settings respectively. -See session_settings and pe_settings for more information on available +See session_settings and pe_settings for more information on available options.

    -
    -

    set_peer_proxy() set_web_seed_proxy() set_tracker_proxy() set_dht_proxy()

    +
    +

    set_peer_proxy() set_web_seed_proxy() set_tracker_proxy() set_dht_proxy()

     void set_peer_proxy(proxy_settings const& s);
    @@ -998,16 +1030,16 @@ void set_dht_proxy(proxy_settings const& s);
     sets the proxy settings for different kinds of connections, bittorrent peers,
     web seeds, trackers and the DHT traffic.

    set_peer_proxy affects regular bittorrent peers. set_web_seed_proxy -affects only web seeds. see HTTP seeding.

    +affects only web seeds. see HTTP seeding.

    set_tracker_proxy only affects HTTP tracker connections (UDP tracker connections are affected if the given proxy supports UDP, e.g. SOCKS5).

    set_dht_proxy affects the DHT messages. Since they are sent over UDP, it only has any effect if the proxy supports UDP.

    For more information on what settings are available for proxies, see -proxy_settings.

    +proxy_settings.

    -
    -

    peer_proxy() web_seed_proxy() tracker_proxy() dht_proxy()

    +
    +

    peer_proxy() web_seed_proxy() tracker_proxy() dht_proxy()

     proxy_settings const& peer_proxy() const;
    @@ -1019,8 +1051,8 @@ proxy_settings const& dht_proxy() const;
     

    These functions returns references to their respective current settings.

    The dht_proxy is not available when DHT is disabled.

    -
    -

    start_dht() stop_dht() set_dht_settings() dht_state()

    +
    +

    start_dht() stop_dht() set_dht_settings() dht_state()

     void start_dht(entry const& startup_state);
    @@ -1080,8 +1112,8 @@ that are ready to replace a failing node, it will be replaced immediately,
     this limit is only used to clear out nodes that don't have any node that can
     replace them.

    -
    -

    add_dht_node() add_dht_router()

    +
    +

    add_dht_node() add_dht_router()

     void add_dht_node(std::pair<std::string, int> const& node);
    @@ -1099,8 +1131,8 @@ for bootstrapping, to keep the load off them.

    An example routing node that you could typically add is router.bittorrent.com.

    -
    -

    start_lsd() stop_lsd()

    +
    +

    start_lsd() stop_lsd()

     void start_lsd();
    @@ -1112,8 +1144,8 @@ the infohashes of all the non-private torrents on the local network to
     look for peers on the same swarm within multicast reach.

    It is turned off by default.

    -
    -

    start_upnp() stop_upnp()

    +
    +

    start_upnp() stop_upnp()

     upnp* start_upnp();
    @@ -1124,12 +1156,12 @@ void stop_upnp();
     port are attempted to be forwarded on local UPnP router devices.

    The upnp object returned by start_upnp() can be used to add and remove arbitrary port mappings. Mapping status is returned through the -portmap_alert and the portmap_error_alert. The object will be valid until -stop_upnp() is called. See UPnP and NAT-PMP.

    +portmap_alert and the portmap_error_alert. The object will be valid until +stop_upnp() is called. See UPnP and NAT-PMP.

    It is off by default.

    -
    -

    start_natpmp() stop_natpmp()

    +
    +

    start_natpmp() stop_natpmp()

     natpmp* start_natpmp();
    @@ -1140,13 +1172,13 @@ void stop_natpmp();
     port are attempted to be forwarded on the router through NAT-PMP.

    The natpmp object returned by start_natpmp() can be used to add and remove arbitrary port mappings. Mapping status is returned through the -portmap_alert and the portmap_error_alert. The object will be valid until -stop_natpmp() is called. See UPnP and NAT-PMP.

    +portmap_alert and the portmap_error_alert. The object will be valid until +stop_natpmp() is called. See UPnP and NAT-PMP.

    It is off by default.

    -
    -

    entry

    +
    +

    entry

    The entry class represents one node in a bencoded hierarchy. It works as a variant type, it can be either a list, a dictionary (std::map), an integer or a string. This is its synopsis:

    @@ -1209,8 +1241,8 @@ public: };

    TODO: finish documentation of entry.

    -
    -

    integer() string() list() dict() type()

    +
    +

    integer() string() list() dict() type()

     integer_type& integer();
    @@ -1225,7 +1257,7 @@ dictionary_type const& dict() const;
     

    The integer(), string(), list() and dict() functions are accessors that return the respective type. If the entry object isn't of the -type you request, the accessor will throw type_error (which derives from +type you request, the accessor will throw type_error (which derives from std::runtime_error). You can ask an entry for its type through the type() function.

    The print() function is there for debug purposes only.

    @@ -1259,11 +1291,11 @@ if (entry* i = torrent_file.find_key("announce")) std::cout << tracker_url << "\n"; } -

    To make it easier to extract information from a torrent file, the class torrent_info +

    To make it easier to extract information from a torrent file, the class torrent_info exists.

    -
    -

    operator[]

    +
    +

    operator[]

     entry& operator[](char const* key);
    @@ -1281,8 +1313,8 @@ given key, a reference to a newly inserted element at that key.

    existing element at the given key. If the key is not found, it will throw libtorrent::type_error.

    -
    -

    find_key()

    +
    +

    find_key()

     entry* find_key(char const* key);
    @@ -1296,11 +1328,11 @@ element cannot be found, they will return 0. If an element with the given
     key is found, the return a pointer to it.

    -
    -

    torrent_info

    +
    +

    torrent_info

    In previous versions of libtorrent, this class was also used for creating torrent files. This functionality has been moved to create_torrent, see -make_torrent.

    +make_torrent.

    The torrent_info has the following synopsis:

     class torrent_info
    @@ -1359,8 +1391,8 @@ public:
             int metadata_size() const;
     };
     
    -
    -

    torrent_info()

    +
    +

    torrent_info()

     torrent_info(sha1_hash const& info_hash);
    @@ -1376,25 +1408,25 @@ from the swarm.

    The constructor that takes a lazy_entry will create a torrent_info object from the information found in the given torrent_file. The lazy_entry represents a tree node in an bencoded file. To load an ordinary .torrent file -into a lazy_entry, use lazy_bdecode(), see bdecode() bencode().

    +into a lazy_entry, use lazy_bdecode(), see bdecode() bencode().

    The version that takes a buffer pointer and a size will decode it as a .torrent file and initialize the torrent_info object for you.

    The version that takes a filename will simply load the torrent file and decode it inside the constructor, for convenience. This might not be the most suitable for applications that want to be able to report detailed errors on what might go wrong.

    -
    -

    add_tracker()

    +
    +

    add_tracker()

     void add_tracker(std::string const& url, int tier = 0);
     

    add_tracker() adds a tracker to the announce-list. The tier determines the order in -which the trackers are to be tried. For more information see trackers().

    +which the trackers are to be tried. For more information see trackers().

    -
    -

    files()

    +
    +

    files()

     file_storage const& file() const;
    @@ -1408,8 +1440,8 @@ to make its mapping differ from the one in the torrent file.

    For more information on the file_storage object, see the separate document on how to create torrents.

    -
    -

    begin_files() end_files() rbegin_files() rend_files()

    +
    +

    begin_files() end_files() rbegin_files() rend_files()

     file_iterator begin_files() const;
    @@ -1451,8 +1483,8 @@ the original string is preserved in 
    -

    num_files() file_at()

    +
    +

    num_files() file_at()

     int num_files() const;
    @@ -1462,8 +1494,8 @@ file_entry const& file_at(int index) const;
     

    If you need index-access to files you can use the num_files() and file_at() to access files using indices.

    -
    -

    map_block()

    +
    +

    map_block()

     std::vector<file_slice> map_block(int piece, size_type offset
    @@ -1488,8 +1520,8 @@ as argument. The offsetsize is the number of bytes this range is. The size + offset
     will never be greater than the file size.

    -
    -

    map_file()

    +
    +

    map_file()

     peer_request map_file(int file_index, size_type file_offset
    @@ -1516,8 +1548,8 @@ struct peer_request
     + size is not allowed to be greater than the file size. file_index
     must refer to a valid file, i.e. it cannot be >= num_files().

    -
    -

    url_seeds() add_url_seed()

    +
    +

    url_seeds() add_url_seed()

     std::vector<std::string> const& url_seeds() const;
    @@ -1528,10 +1560,10 @@ void add_url_seed(std::string const& url);
     vector of those urls. If you're creating a torrent file, add_url_seed()
     adds one url to the list of url-seeds. Currently, the only transport protocol
     supported for the url is http.

    -

    See HTTP seeding for more information.

    +

    See HTTP seeding for more information.

    -
    -

    trackers()

    +
    +

    trackers()

     std::vector<announce_entry> const& trackers() const;
    @@ -1550,8 +1582,8 @@ struct announce_entry
     };
     
    -
    -

    total_size() piece_length() piece_size() num_pieces()

    +
    +

    total_size() piece_length() piece_size() num_pieces()

     size_type total_size() const;
    @@ -1568,8 +1600,8 @@ the piece index as argument and gives you the exact size of that piece. It will
     be the same as piece_length() except in the case of the last piece, which may
     be smaller.

    -
    -

    hash_for_piece() hash_for_piece_ptr() info_hash()

    +
    +

    hash_for_piece() hash_for_piece_ptr() info_hash()

     size_type piece_size(unsigned int index) const;
    @@ -1579,12 +1611,12 @@ char const* hash_for_piece_ptr(unsigned int index) const;
     

    hash_for_piece() takes a piece-index and returns the 20-bytes sha1-hash for that piece and info_hash() returns the 20-bytes sha1-hash for the info-section of the -torrent file. For more information on the sha1_hash, see the big_number class. +torrent file. For more information on the sha1_hash, see the big_number class. hash_for_piece_ptr() returns a pointer to the 20 byte sha1 digest for the piece. Note that the string is not null-terminated.

    -
    -

    name() comment() creation_date() creator()

    +
    +

    name() comment() creation_date() creator()

     std::string const& name() const;
    @@ -1594,15 +1626,15 @@ boost::optional<boost::posix_time::ptime> creation_date() const;
     

    name() returns the name of the torrent.

    comment() returns the comment associated with the torrent. If there's no comment, -it will return an empty string. creation_date() returns a boost::posix_time::ptime +it will return an empty string. creation_date() returns a boost::posix_time::ptime object, representing the time when this torrent file was created. If there's no time stamp in the torrent file, this will return a date of January 1:st 1970.

    Both the name and the comment is UTF-8 encoded strings.

    creator() returns the creator string in the torrent. If there is no creator string it will return an empty string.

    -
    -

    priv()

    +
    +

    priv()

     bool priv() const;
    @@ -1611,8 +1643,8 @@ bool priv() const;
     

    priv() returns true if this torrent is private. i.e., it should not be distributed on the trackerless network (the kademlia DHT).

    -
    -

    nodes()

    +
    +

    nodes()

     std::vector<std::pair<std::string, int> > const& nodes() const;
    @@ -1621,8 +1653,8 @@ std::vector<std::pair<std::string, int> > const& nodes() const;
     

    If this torrent contains any DHT nodes, they are put in this vector in their original form (host name and port number).

    -
    -

    add_node()

    +
    +

    add_node()

     void add_node(std::pair<std::string, int> const& node);
    @@ -1631,8 +1663,8 @@ void add_node(std::pair<std::string, int> const& node);
     

    This is used when creating torrent. Use this to add a known DHT node. It may be used, by the client, to bootstrap into the DHT network.

    -
    -

    metadata() metadata_size()

    +
    +

    metadata() metadata_size()

     boost::shared_array<char> metadata() const;
    @@ -1643,8 +1675,8 @@ int metadata_size() const;
     of the metadata is returned by metadata_size().

    -
    -

    torrent_handle

    +
    +

    torrent_handle

    You will usually have to store your torrent handles somewhere, since it's the object through which you retrieve information about the torrent and aborts the torrent. Its declaration looks like this:

    @@ -1723,6 +1755,7 @@ struct torrent_handle void auto_managed(bool m) const; bool has_metadata() const; + bool set_metadata(char const* buf, int size) const; boost::filesystem::path save_path() const; void move_storage(boost::filesystem::path const& save_path) const; @@ -1741,14 +1774,14 @@ valid handle. If you try to perform any operation on an uninitialized handle, it will throw invalid_handle.

    Warning

    -

    All operations on a torrent_handle may throw invalid_handle +

    All operations on a torrent_handle may throw invalid_handle exception, in case the handle is no longer refering to a torrent. There is one exception is_valid() will never throw. Since the torrents are processed by a background thread, there is no guarantee that a handle will remain valid between two calls.

    -
    -

    piece_priority() prioritize_pieces() piece_priorities()

    +
    +

    piece_priority() prioritize_pieces() piece_priorities()

     void piece_priority(int index, int priority) const;
    @@ -1788,8 +1821,8 @@ in the vector.

    piece_priorities returns a vector with one element for each piece in the torrent. Each element is the current priority of that piece.

    -
    -

    file_priority() prioritize_files() file_priorities()

    +
    +

    file_priority() prioritize_files() file_priorities()

     void file_priority(int index, int priority) const;
    @@ -1809,8 +1842,8 @@ sets the priorities of all the pieces in the torrent based on the vector.

    to match the file priorities. In order to maintain sepcial priorities for particular pieces, piece_priority has to be called again for those pieces.

    -
    -

    file_progress()

    +
    +

    file_progress()

     void file_progress(std::vector<size_type>& fp);
    @@ -1818,22 +1851,22 @@ void file_progress(std::vector<size_type>& fp);
     

    This function fills in the supplied vector with the the number of bytes downloaded of each file in this torrent. The progress values are ordered the same as the files -in the torrent_info. This operation is not very cheap. Its complexity is O(n + mj). +in the torrent_info. This operation is not very cheap. Its complexity is O(n + mj). Where n is the number of files, m is the number of downloading pieces and j is the number of blocks in a piece.

    -
    -

    save_path()

    +
    +

    save_path()

     boost::filesystem::path save_path() const;
     
    -

    save_path() returns the path that was given to add_torrent() when this torrent +

    save_path() returns the path that was given to add_torrent() when this torrent was started.

    -
    -

    move_storage()

    +
    +

    move_storage()

     void move_storage(boost::filesystem::path const& save_path) const;
    @@ -1845,8 +1878,8 @@ the same drive as the original save path. Since disk IO is performed in a separa
     thread, this operation is also asynchronous. Once the operation completes, the
     storage_moved_alert is generated, with the new path as the message.

    -
    -

    get_storage_impl()

    +
    +

    get_storage_impl()

     storage_interface* get_storage_impl() const;
    @@ -1855,8 +1888,8 @@ storage_interface* get_storage_impl() const;
     

    Returns the storage implementation for this torrent. This depends on the storage contructor function that was passed to session::add_torrent.

    -
    -

    force_reannounce()

    +
    +

    force_reannounce()

     void force_reannounce() const;
    @@ -1867,8 +1900,8 @@ void force_reannounce(boost::posix_time::time_duration) const;
     peers. The second overload of force_reannounce that takes a time_duration as
     argument will schedule a reannounce in that amount of time from now.

    -
    -

    scrape_tracker()

    +
    +

    scrape_tracker()

     void scrape_tracker() const;
    @@ -1878,11 +1911,11 @@ void scrape_tracker() const;
     tracker for statistics such as total number of incomplete peers, complete peers, number of
     downloads etc.

    This request will specifically update the num_complete and num_incomplete fields in -the torrent_status struct once it completes. When it completes, it will generate a -scrape_reply_alert. If it fails, it will generate a scrape_failed_alert.

    +the torrent_status struct once it completes. When it completes, it will generate a +scrape_reply_alert. If it fails, it will generate a scrape_failed_alert.

    -
    -

    connect_peer()

    +
    +

    connect_peer()

     void connect_peer(asio::ip::tcp::endpoint const& adr, int source = 0) const;
    @@ -1892,12 +1925,12 @@ void connect_peer(asio::ip::tcp::endpoint const& adr, int source = 0) const;
     torrent. If the peer does not respond, or is not a member of this torrent, it will simply
     be disconnected. No harm can be done by using this other than an unnecessary connection
     attempt is made. If the torrent is uninitialized or in queued or checking mode, this
    -will throw invalid_handle. The second (optional) argument will be bitwised ORed into
    -the source mask of this peer. Typically this is one of the source flags in peer_info.
    +will throw invalid_handle. The second (optional) argument will be bitwised ORed into
    +the source mask of this peer. Typically this is one of the source flags in peer_info.
     i.e. tracker, pex, dht etc.

    -
    -

    name()

    +
    +

    name()

     std::string name() const;
    @@ -1907,8 +1940,8 @@ std::string name() const;
     case the torrent was started without metadata, and hasn't completely received it yet,
     it returns the name given to it when added to the session. See session::add_torrent.

    -
    -

    set_ratio()

    +
    +

    set_ratio()

     void set_ratio(float ratio) const;
    @@ -1922,8 +1955,8 @@ attempt to upload in return for each download. e.g. if set to 2, the client will
     2 bytes for every byte received. The default setting for this is 0, which will make it work
     as a standard client.

    -
    -

    set_upload_limit() set_download_limit() upload_limit() download_limit()

    +
    +

    set_upload_limit() set_download_limit() upload_limit() download_limit()

     void set_upload_limit(int limit) const;
    @@ -1941,8 +1974,8 @@ limit.

    upload_limit and download_limit will return the current limit setting, for upload and download, respectively.

    -
    -

    set_sequential_download() is_sequential_download()

    +
    +

    set_sequential_download() is_sequential_download()

     void set_sequential_download(bool sd);
    @@ -1956,8 +1989,8 @@ used sparingly.

    is_sequential_download() returns true if this torrent is downloading in sequence, and false otherwise.

    -
    -

    set_peer_upload_limit() set_peer_download_limit()

    +
    +

    set_peer_upload_limit() set_peer_download_limit()

     void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
    @@ -1967,8 +2000,8 @@ void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
     

    Works like set_upload_limit and set_download_limit respectively, but controls individual peer instead of the whole torrent.

    -
    -

    pause() resume() is_paused()

    +
    +

    pause() resume() is_paused()

     void pause() const;
    @@ -1980,14 +2013,14 @@ bool is_paused() const;
     When a torrent is paused, it will however remember all share ratios to all peers and remember
     all potential (not connected) peers. You can use is_paused() to determine if a torrent
     is currently paused. Torrents may be paused automatically if there is a file error (e.g. disk full)
    -or something similar. See file_error_alert.

    +or something similar. See file_error_alert.

    is_paused() only returns true if the torrent itself is paused. If the torrent is not running because the session is paused, this still returns false. To know if a torrent is active or not, you need to inspect both torrent_handle::is_paused() and session::is_paused().

    -
    -

    force_recheck()

    +
    +

    force_recheck()

     void force_recheck() const;
    @@ -1999,8 +2032,8 @@ will be added to the checking queue, and will be checked (all the files will be
     compared to the piece hashes). Once the check is complete, the torrent will start connecting
     to peers again, as normal.

    -
    -

    clear_error()

    +
    +

    clear_error()

     void clear_error() const;
    @@ -2009,8 +2042,8 @@ void clear_error() const;
     

    If the torrent is in an error state (i.e. torrent_status::error is non-empty), this will clear the error and start the torrent again.

    -
    -

    resolve_countries()

    +
    +

    resolve_countries()

     void resolve_countries(bool r);
    @@ -2018,12 +2051,12 @@ bool resolve_countries() const;
     

    Sets or gets the flag that derermines if countries should be resolved for the peers of this -torrent. It defaults to false. If it is set to true, the peer_info structure for the peers -in this torrent will have their country member set. See peer_info for more information +torrent. It defaults to false. If it is set to true, the peer_info structure for the peers +in this torrent will have their country member set. See peer_info for more information on how to interpret this field.

    -
    -

    is_seed()

    +
    +

    is_seed()

     bool is_seed() const;
    @@ -2031,8 +2064,8 @@ bool is_seed() const;
     

    Returns true if the torrent is in seed mode (i.e. if it has finished downloading).

    -
    -

    is_auto_managed() auto_managed()

    +
    +

    is_auto_managed() auto_managed()

     bool is_auto_managed() const;
    @@ -2041,22 +2074,29 @@ void auto_managed(bool m) const;
     

    is_auto_managed() returns true if this torrent is currently auto managed. auto_managed() changes whether the torrent is auto managed or not. For more info, -see queuing.

    +see queuing.

    -
    -

    has_metadata()

    +
    +

    has_metadata() set_metadata()

     bool has_metadata() const;
    +bool set_metadata(char const* buf, int size) const;
     
    -

    Returns true if this torrent has metadata (either it was started from a .torrent file or the -metadata has been downloaded). The only scenario where this can return false is when the torrent -was started torrent-less (i.e. with just an info-hash and tracker ip). Note that if the torrent -doesn't have metadata, the member get_torrent_info() will throw.

    +

    has_metadata returns true if this torrent has metadata (either it was started from a +.torrent file or the metadata has been downloaded). The only scenario where this can return +false is when the torrent was started torrent-less (i.e. with just an info-hash and tracker +ip). Note that if the torrent doesn't have metadata, the member get_torrent_info() will +throw.

    +

    set_metadata expects the info section of metadata. i.e. The buffer passed in will be +hashed and verified against the info-hash. If it fails, a metadata_failed_alert will be +generated. If it passes, a metadata_received_alert is generated. The function returns +true if the metadata is successfully set on the torrent, and false otherwise. If the torrent +already has metadata, this function will not affect the torrent, and false will be returned.

    -
    -

    set_tracker_login()

    +
    +

    set_tracker_login()

     void set_tracker_login(std::string const& username
    @@ -2066,8 +2106,8 @@ void set_tracker_login(std::string const& username
     

    set_tracker_login() sets a username and password that will be sent along in the HTTP-request of the tracker announce. Set this if the tracker requires authorization.

    -
    -

    trackers() replace_trackers()

    +
    +

    trackers() replace_trackers()

     std::vector<announce_entry> const& trackers() const;
    @@ -2081,10 +2121,10 @@ which this tracker is tried. If you want libtorrent to use another list of
     trackers for this torrent, you can use replace_trackers() which takes
     a list of the same form as the one returned from trackers() and will
     replace it. If you want an immediate effect, you have to call
    -force_reannounce().

    +force_reannounce().

    -
    -

    add_url_seed() remove_url_seed() url_seeds()

    +
    +

    add_url_seed() remove_url_seed() url_seeds()

     void add_url_seed(std::string const& url);
    @@ -2099,10 +2139,10 @@ paused, queued, checking or seeding. url_seeds() return a set of the url seeds
     currently in this torrent. Note that urls that fails may be removed
     automatically from the list.

    -

    See HTTP seeding for more information.

    +

    See HTTP seeding for more information.

    -
    -

    queue_position() queue_position_up() queue_position_down() queue_position_top() queue_position_bottom()

    +
    +

    queue_position() queue_position_up() queue_position_down() queue_position_top() queue_position_bottom()

     int queue_position() const;
    @@ -2124,20 +2164,20 @@ the closer the torrent is to the front of the line to be started.

    closer to the front and down means closer to the back of the queue. Top and bottom refers to the front and the back of the queue respectively.

    -
    -

    use_interface()

    +
    +

    use_interface()

     void use_interface(char const* net_interface) const;
     

    use_interface() sets the network interface this torrent will use when it opens outgoing -connections. By default, it uses the same interface as the session uses to listen on. The +connections. By default, it uses the same interface as the session uses to listen on. The parameter must be a string containing an ip-address (either an IPv4 or IPv6 address). If the string does not conform to this format and exception is thrown.

    -
    -

    info_hash()

    +
    +

    info_hash()

     sha1_hash info_hash() const;
    @@ -2145,8 +2185,8 @@ sha1_hash info_hash() const;
     

    info_hash() returns the info-hash for the torrent.

    -
    -

    set_max_uploads() set_max_connections()

    +
    +

    set_max_uploads() set_max_connections()

     void set_max_uploads(int max_uploads) const;
    @@ -2160,17 +2200,17 @@ connections are used up, incoming connections may be refused or poor connections
     This must be at least 2. The default is unlimited number of connections. If -1 is given to the
     function, it means unlimited.

    -
    -

    save_resume_data()

    +
    +

    save_resume_data()

     void save_resume_data() const;
     
    -

    save_resume_data() generates fast-resume data and returns it as an entry. This entry -is suitable for being bencoded. For more information about how fast-resume works, see fast resume.

    +

    save_resume_data() generates fast-resume data and returns it as an entry. This entry +is suitable for being bencoded. For more information about how fast-resume works, see fast resume.

    This operation is asynchronous, save_resume_data will return immediately. The resume data -is delivered when it's done through an save_resume_data_alert.

    +is delivered when it's done through an save_resume_data_alert.

    The fast resume data will be empty in the following cases:

      @@ -2178,19 +2218,29 @@ is delivered when it's done through an metadata from peers extension) +(see libtorrent's metadata from peers extension)

    Note that by the time you receive the fast resume data, it may already be invalid if the torrent -is still downloading! The recommended practice is to first pause the torrent, then generate the -fast resume data, and then close it down. Make sure to not remove_torrent() before you receive -the save_resume_data_alert though. Only pause the torrent before you save the resume data -if you will remove the torrent afterwards. There's no need to pause when saving intermittent -resume data.

    -

    In full allocation mode the reume data is never invalidated by subsequent +is still downloading! The recommended practice is to first pause the session, then generate the +fast resume data, and then close it down. Make sure to not remove_torrent() before you receive +the save_resume_data_alert though. There's no need to pause when saving intermittent resume data.

    +
    +

    Warning

    +

    If you pause every torrent individually instead of pausing the session, every torrent +will have its paused state saved in the resume data!

    +
    +
    +

    Note

    +

    It is typically a good idea to save resume data whenever a torrent is completed or paused. In those +cases you don't need to pause the torrent or the session, since the torrent will do no more writing +to its files. If you save resume data for torrents when they are paused, you can accelerate the +shutdown process by not saving resume data again for paused torrents.

    +

    In full allocation mode the reume data is never invalidated by subsequent writes to the files, since pieces won't move around. This means that you don't need to pause before writing resume data in full or sparse mode. If you don't, however, any data written to -disk after you saved resume data and before the session closed is lost.

    +disk after you saved resume data and before the session closed is lost.

    +

    It also means that if the resume data is out dated, libtorrent will not re-check the files, but assume that it is fairly recent. The assumption is that it's better to loose a little bit than to re-check the entire file.

    @@ -2200,13 +2250,14 @@ closing down.

     int num_resume_data = 0;
     std::vector<torrent_handle> handles = ses.get_torrents();
    +ses.pause();
     for (std::vector<torrent_handle>::iterator i = handles.begin();
             i != handles.end(); ++i)
     {
             torrent_handle& h = *i;
             if (!h.has_metadata()) continue;
    +        if (!h.is_valid()) continue;
     
    -        h.pause();
             h.save_resume_data();
             ++num_resume_data;
     }
    @@ -2235,19 +2286,19 @@ while (num_resume_data > 0)
     }
     
    -
    -

    status()

    +
    +

    status()

     torrent_status status() const;
     

    status() will return a structure with information about the status of this -torrent. If the torrent_handle is invalid, it will throw invalid_handle exception. -See torrent_status.

    +torrent. If the torrent_handle is invalid, it will throw invalid_handle exception. +See torrent_status.

    -
    -

    get_download_queue()

    +
    +

    get_download_queue()

     void get_download_queue(std::vector<partial_piece_info>& queue) const;
    @@ -2299,8 +2350,8 @@ a state (state) which
     is 0 or 1, but at the end of the torrent blocks may be requested by more peers in parallel to
     speed things up.

    -
    -

    get_peer_info()

    +
    +

    get_peer_info()

     void get_peer_info(std::vector<peer_info>&) const;
    @@ -2308,25 +2359,25 @@ void get_peer_info(std::vector<peer_info>&) const;
     

    get_peer_info() takes a reference to a vector that will be cleared and filled with one entry for each peer connected to this torrent, given the handle is valid. If the -torrent_handle is invalid, it will throw invalid_handle exception. Each entry in -the vector contains information about that particular peer. See peer_info.

    +torrent_handle is invalid, it will throw invalid_handle exception. Each entry in +the vector contains information about that particular peer. See peer_info.

    -
    -

    get_torrent_info()

    +
    +

    get_torrent_info()

     torrent_info const& get_torrent_info() const;
     
    -

    Returns a const reference to the torrent_info object associated with this torrent. -This reference is valid as long as the torrent_handle is valid, no longer. If the -torrent_handle is invalid or if it doesn't have any metadata, invalid_handle +

    Returns a const reference to the torrent_info object associated with this torrent. +This reference is valid as long as the torrent_handle is valid, no longer. If the +torrent_handle is invalid or if it doesn't have any metadata, invalid_handle exception will be thrown. The torrent may be in a state without metadata only if it was started without a .torrent file, i.e. by using the libtorrent extension of just supplying a tracker and info-hash.

    -
    -

    is_valid()

    +
    +

    is_valid()

     bool is_valid() const;
    @@ -2336,12 +2387,12 @@ bool is_valid() const;
     or if the torrent it refers to has been aborted. Note that a handle may become invalid after
     it has been added to the session. Usually this is because the storage for the torrent is
     somehow invalid or if the filenames are not allowed (and hence cannot be opened/created) on
    -your filesystem. If such an error occurs, a file_error_alert is generated and all handles
    +your filesystem. If such an error occurs, a file_error_alert is generated and all handles
     that refers to that torrent will become invalid.

    -
    -

    torrent_status

    +
    +

    torrent_status

    It contains the following fields:

     struct torrent_status
    @@ -2514,7 +2565,7 @@ be slightly smaller than the other rates, but if projected over a long time
     

    num_peers is the number of peers this torrent currently is connected to. Peer connections that are in the half-open state (is attempting to connect) or are queued for later connection attempt do not count. Although they are -visible in the peer list when you call get_peer_info().

    +visible in the peer list when you call get_peer_info().

    num_complete and num_incomplete are set to -1 if the tracker did not send any scrape data in its announce reply. This data is optional and may not be available from all trackers. If these are not -1, they are the total @@ -2552,7 +2603,7 @@ copies is set to -1.

    block_size is the size of a block, in bytes. A block is a sub piece, it is the number of bytes that each piece request asks for and the number of bytes that each bit in the partial_piece_info's bitset represents -(see get_download_queue()). This is typically 16 kB, but it may be +(see get_download_queue()). This is typically 16 kB, but it may be larger if the pieces are larger.

    num_uploads is the number of unchoked peers in this torrent.

    num_connections is the number of peer connections this torrent has, including @@ -2562,7 +2613,7 @@ always <= num_peersconnections_limit is the set limit of number of connections for this torrent.

    storage_mode is one of storage_mode_allocate, storage_mode_sparse or storage_mode_compact. Identifies which storage mode this torrent is being saved -with. See Storage allocation.

    +with. See Storage allocation.

    up_bandwidth_queue and down_bandwidth_queue are the number of peers in this torrent that are waiting for more bandwidth quota from the torrent rate limiter. This can determine if the rate you get from this torrent is bound by the torrents @@ -2570,7 +2621,7 @@ limit or not. If there is no limit set on this torrent, the peers might still be waiting for bandwidth quota from the global limiter, but then they are counted in the session_status object.

    all_time_upload and all_time_download are accumulated upload and download -byte counters. They are saved in and restored from resume data to keep totals +payload byte counters. They are saved in and restored from resume data to keep totals across sessions.

    active_time and seeding_time are second counters. They keep track of the number of seconds this torrent has been active (not paused) and the number of @@ -2579,14 +2630,14 @@ seconds it has been active while being a seed.

    seed_rank is a rank of how important it is to seed the torrent, it is used to determine which torrents to seed and which to queue. It is based on the peer -to seed ratio from the tracker scrape. For more information, see queuing.

    +to seed ratio from the tracker scrape. For more information, see queuing.

    last_scrape is the number of seconds since this torrent acquired scrape data. If it has never done that, this value is -1.

    has_incoming is true if there has ever been an incoming connection attempt to this torrent.'

    -
    -

    peer_info

    +
    +

    peer_info

    It contains the following fields:

     struct peer_info
    @@ -2691,6 +2742,7 @@ struct peer_info
             int download_rate_peak;
             int upload_rate_peak;
     
    +        float progress;
     };
     

    The flags attribute tells you in which state the peer is. It is set to @@ -2715,7 +2767,7 @@ any combination of the enums above. The following table describes each flag:

    support_extensions means that this peer supports the -extension protocol. +extension protocol. local_connection The connection was initiated by us, the peer has a @@ -2827,7 +2879,7 @@ limits.

    The ip field is the IP-address to this peer. The type is an asio endpoint. For -more info, see the asio documentation.

    +more info, see the asio documentation.

    up_speed and down_speed contains the current upload and download speed we have to and from this peer (including any protocol messages). The transfer rates of payload data only are found in payload_up_speed and payload_down_speed. @@ -2858,12 +2910,12 @@ and used for the peer's send buffer, respectively.

    allocated and used as receive buffer, respectively.

    num_hashfails is the number of pieces this peer has participated in sending us that turned out to fail the hash check.

    -

    country is the two letter ISO 3166 country code for the country the peer +

    country is the two letter ISO 3166 country code for the country the peer is connected from. If the country hasn't been resolved yet, both chars are set to 0. If the resolution failed for some reason, the field is set to "--". If the resolution service returns an invalid country code, it is set to "!!". The countries.nerd.dk service is used to look up countries. This field will -remain set to 0 unless the torrent is set to resolve countries, see resolve_countries().

    +remain set to 0 unless the torrent is set to resolve countries, see resolve_countries().

    inet_as_name is the name of the AS this peer is located in. This might be an empty string if there is no name in the geo ip database.

    inet_as is the AS number the peer is located in.

    @@ -2909,9 +2961,10 @@ estimated by timing the the tcp c

    download_rate_peak and upload_rate_peak are the highest download and upload rates seen on this connection. They are given in bytes per second. This number is reset to 0 on reconnect.

    +

    progress is the progress of the peer.

    -
    -

    session_settings

    +
    +

    session_settings

    You have some control over tracker requests through the session_settings object. You create it and fill it with your settings and then use session::set_settings() to apply them. You have control over proxy and authorization settings and also the user-agent @@ -2979,6 +3032,9 @@ struct session_settings int max_peerlist_size; int min_announce_interval; + + bool prioritize_partial_pieces; + int auto_manage_startup; };

    user_agent this is the client identification to the tracker. @@ -3108,9 +3164,9 @@ message or a time out.

    are kept in memory after the torrent becomes a seed or not. If it is set to true the hashes are freed once the torrent is a seed (they're not needed anymore since the torrent won't download anything more). If it's set -to false they are not freed. If they are freed, the torrent_info returned +to false they are not freed. If they are freed, the torrent_info returned by get_torrent_info() will return an object that may be incomplete, that -cannot be passed back to add_torrent() for instance.

    +cannot be passed back to add_torrent() for instance.

    upnp_ignore_nonrouters indicates whether or not the UPnP implementation should ignore any broadcast response from a device whose address is not the configured router for this machine. i.e. it's a way to not talk to other @@ -3143,7 +3199,7 @@ to peers if a previous socket to that peer and port is in peer_tos determines the TOS byte set in the IP header of every packet sent to peers (including web seeds). The default value for this is 0x0 (no marking). One potentially useful TOS mark is 0x20, this represents -the QBone scavenger service. For more details, see QBSS.

    +the QBone scavenger service. For more details, see QBSS.

    active_downloads and active_seeds controls how many active seeding and downloading torrents the queuing mechanism allows. The target number of active torrents is max(active_downloads, active_seeds). active_downloads and @@ -3165,12 +3221,12 @@ slow torrents.

    auto_manage_interval is the number of seconds between the torrent queue is updated, and rotated.

    share_ratio_limit is the upload / download ratio limit for considering a -seeding torrent have met the seed limit criteria. See queuing.

    +seeding torrent have met the seed limit criteria. See queuing.

    seed_time_ratio_limit is the seeding time / downloading time ratio limit -for considering a seeding torrent to have met the seed limit criteria. See queuing.

    +for considering a seeding torrent to have met the seed limit criteria. See queuing.

    seed_time_limit is the limit on the time a torrent has been an active seed (specified in seconds) before it is considered having met the seed limit criteria. -See queuing.

    +See queuing.

    close_redundant_connections specifies whether libtorrent should close connections where both ends have no utility in keeping the connection open. For instance if both ends have completed their downloads, there's no point @@ -3194,9 +3250,17 @@ added to the list.

    for a tracker. This is specified in seconds, defaults to 5 minutes and is used as a sanity check on what is returned from a tracker. It mitigates hammering misconfigured trackers.

    +

    If prioritize_partial_pieces is true, partial pieces are picked +before pieces that are more rare. If false, rare pieces are always +prioritized, unless the number of partial pieces is growing out of +proportion.

    +

    auto_manage_startup is the number of seconds a torrent is considered +active after it was started, regardless of upload and download speed. This +is so that newly started torrents are not considered inactive until they +have a fair chance to start downloading.

    -
    -

    pe_settings

    +
    +

    pe_settings

    The pe_settings structure is used to control the settings related to peer protocol encryption:

    @@ -3252,8 +3316,8 @@ remains unchanged.
     
     

    prefer_rc4 can be set to true if you want to prefer the RC4 encrypted stream.

    -
    -

    proxy_settings

    +
    +

    proxy_settings

    The proxy_settings structs contains the information needed to direct certain traffic to a proxy.

    @@ -3291,16 +3355,16 @@ options are available:

    • none - This is the default, no proxy server is used, all other fields are ignored.
    • -
    • socks4 - The server is assumed to be a SOCKS4 server that +
    • socks4 - The server is assumed to be a SOCKS4 server that requires a username.
    • -
    • socks5 - The server is assumed to be a SOCKS5 server (RFC 1928) that +
    • socks5 - The server is assumed to be a SOCKS5 server (RFC 1928) that does not require any authentication. The username and password are ignored.
    • socks5_pw - The server is assumed to be a SOCKS5 server that supports -plain text username and password authentication (RFC 1929). The username +plain text username and password authentication (RFC 1929). The username and password specified may be sent to the proxy if it requires.
    • http - The server is assumed to be an HTTP proxy. If the transport used for the connection is non-HTTP, the server is assumed to support the -CONNECT method. i.e. for web seeds and HTTP trackers, a plain proxy will +CONNECT method. i.e. for web seeds and HTTP trackers, a plain proxy will suffice. The proxy is assumed to not require authorization. The username and password will not be used.
    • http_pw - The server is assumed to be an HTTP proxy that requires @@ -3308,8 +3372,8 @@ user authorization. The username and password will be sent to the proxy.
    -
    -

    ip_filter

    +
    +

    ip_filter

    The ip_filter class is a set of rules that uniquely categorizes all ip addresses as allowed or disallowed. The default constructor creates a single rule that allows all addresses (0.0.0.0 - 255.255.255.255 for @@ -3341,8 +3405,8 @@ public: }; -

    -

    ip_filter()

    +
    +

    ip_filter()

     ip_filter()
    @@ -3352,8 +3416,8 @@ ip_filter()
     

    postcondition: access(x) == 0 for every x

    -
    -

    add_rule()

    +
    +

    add_rule()

     void add_rule(address first, address last, int flags);
    @@ -3370,8 +3434,8 @@ means disallowed.

    This means that in a case of overlapping ranges, the last one applied takes precedence.

    -
    -

    access()

    +
    +

    access()

     int access(address const& addr) const;
    @@ -3382,8 +3446,8 @@ can currently be 0 or ip_filter::
     is O(log n), where n is the minimum number of non-overlapping ranges to describe
     the current filter.

    -
    -

    export_filter()

    +
    +

    export_filter()

     boost::tuple<std::vector<ip_range<address_v4> >
    @@ -3398,8 +3462,8 @@ entry in the returned vector is a range with the access control specified in its
     and one for IPv6 addresses.

    -
    -

    big_number

    +
    +

    big_number

    Both the peer_id and sha1_hash types are typedefs of the class big_number. It represents 20 bytes of data. Its synopsis follows:

    @@ -3419,8 +3483,8 @@ public:
     

    The iterators gives you access to individual bytes.

    -
    -

    bitfield

    +
    +

    bitfield

    The bitfiled type stores any number of bits as a bitfield in an array.

     class bitfield
    @@ -3463,8 +3527,8 @@ class bitfield
     };
     
    -
    -

    hasher

    +
    +

    hasher

    This class creates sha1-hashes. Its declaration looks like this:

     class hasher
    @@ -3490,8 +3554,8 @@ call reset() to reini
     

    The sha1-algorithm used was implemented by Steve Reid and released as public domain. For more info, see src/sha1.cpp.

    -
    -

    fingerprint

    +
    +

    fingerprint

    The fingerprint class represents information about a client and its version. It is used to encode this information into the client's peer id.

    This is the class declaration:

    @@ -3548,13 +3612,13 @@ sure not to clash with anybody else. Here are some taken id's:

    -

    There's currently an informal directory of client id's here.

    +

    There's currently an informal directory of client id's here.

    The major, minor, revision and tag parameters are used to identify the version of your client. All these numbers must be within the range [0, 9].

    to_string() will generate the actual string put in the peer-id, and return it.

    -
    -

    UPnP and NAT-PMP

    +
    +

    UPnP and NAT-PMP

    The upnp and natpmp classes contains the state for all UPnP and NAT-PMP mappings, by default 1 or two mappings are made by libtorrent, one for the listen port and one for the DHT port (UDP).

    @@ -3587,8 +3651,8 @@ public:

    discover_device(), close() and rebind() are for internal uses and should not be called directly by clients.

    -
    -

    add_mapping

    +
    +

    add_mapping

     int add_mapping(protocol_type p, int external_port, int local_port);
    @@ -3599,28 +3663,28 @@ int add_mapping(protocol_type p, int external_port, int local_port);
     natpmp::udp for the NAT-PMP class.

    external_port is the port on the external address that will be mapped. This is a hint, you are not guaranteed that this port will be available, and it may -end up being something else. In the portmap_alert notification, the actual +end up being something else. In the portmap_alert notification, the actual external port is reported.

    local_port is the port in the local machine that the mapping should forward to.

    The return value is an index that identifies this port mapping. This is used -to refer to mappings that fails or succeeds in the portmap_error_alert and -portmap_alert respectively. If The mapping fails immediately, the return value +to refer to mappings that fails or succeeds in the portmap_error_alert and +portmap_alert respectively. If The mapping fails immediately, the return value is -1, which means failure. There will not be any error alert notification for mappings that fail with a -1 return value.

    -
    -

    delete_mapping

    +
    +

    delete_mapping

     void delete_mapping(int mapping_index);
     

    This function removes a port mapping. mapping_index is the index that refers -to the mapping you want to remove, which was returned from add_mapping.

    +to the mapping you want to remove, which was returned from add_mapping.

    -
    -

    router_model()

    +
    +

    router_model()

     std::string router_model();
    @@ -3630,10 +3694,10 @@ std::string router_model();
     the router, it can be queried through this function.

    -
    -

    free functions

    -
    -

    identify_client()

    +
    +

    free functions

    +
    +

    identify_client()

     std::string identify_client(peer_id const& id);
    @@ -3643,8 +3707,8 @@ std::string identify_client(peer_id const& id);
     to extract a string describing a client version from its peer-id. It will recognize most clients
     that have this kind of identification in the peer-id.

    -
    -

    client_fingerprint()

    +
    +

    client_fingerprint()

     boost::optional<fingerprint> client_fingerprint(peer_id const& p);
    @@ -3655,23 +3719,23 @@ to automate the identification of clients. It will not be able to identify peers
     standard encodings. Only Azureus style, Shadow's style and Mainline style. This function is
     declared in the header <libtorrent/identify_client.hpp>.

    -
    -

    bdecode() bencode()

    +
    +

    bdecode() bencode()

     template<class InIt> entry bdecode(InIt start, InIt end);
     template<class OutIt> void bencode(OutIt out, const entry& e);
     
    -

    These functions will encode data to bencoded or decode bencoded data.

    -

    The entry class is the internal representation of the bencoded data -and it can be used to retrieve information, an entry can also be build by +

    These functions will encode data to bencoded or decode bencoded data.

    +

    The entry class is the internal representation of the bencoded data +and it can be used to retrieve information, an entry can also be build by the program and given to bencode() to encode it into the OutIt iterator.

    The OutIt and InIt are iterators -(InputIterator and OutputIterator respectively). They -are templates and are usually instantiated as ostream_iterator, -back_insert_iterator or istream_iterator. These +(InputIterator and OutputIterator respectively). They +are templates and are usually instantiated as ostream_iterator, +back_insert_iterator or istream_iterator. These functions will assume that the iterator refers to a character (char). So, if you want to encode entry e into a buffer in memory, you can do it like this:

    @@ -3691,12 +3755,12 @@ const char* buf; // ... entry e = bdecode(buf, buf + data_size); -

    Now we just need to know how to retrieve information from the entry.

    +

    Now we just need to know how to retrieve information from the entry.

    If bdecode() encounters invalid encoded data in the range given to it -it will throw invalid_encoding.

    +it will throw invalid_encoding.

    -
    -

    add_magnet_uri()

    +
    +

    add_magnet_uri()

     torrent_handle add_magnet_uri(session& ses, std::string const& uri
    @@ -3707,11 +3771,11 @@ torrent_handle add_magnet_uri(session& ses, std::string const& uri
     and adds the torrent to the specified session (ses). It returns the
     handle to the newly added torrent, or an invalid handle in case parsing
     failed. To control some initial settings of the torrent, sepcify those in
    -the add_torrent_params, p. See add_torrent().

    -

    For more information about magnet links, see magnet links.

    +the add_torrent_params, p. See add_torrent().

    +

    For more information about magnet links, see magnet links.

    -
    -

    make_magnet_uri()

    +
    +

    make_magnet_uri()

     std::string make_magnet_uri(torrent_handle const& handle);
    @@ -3719,11 +3783,11 @@ std::string make_magnet_uri(torrent_handle const& handle);
     

    Generates a magnet URI from the specified torrent. If the torrent handle is invalid, an empty string is returned.

    -

    For more information about magnet links, see magnet links.

    +

    For more information about magnet links, see magnet links.

    -
    -

    alerts

    +
    +

    alerts

    The pop_alert() function on session is the interface for retrieving alerts, warnings, messages and errors from libtorrent. If no alerts have been posted by libtorrent pop_alert() will return a default initialized @@ -3795,7 +3859,7 @@ alerts that belong to an enabled category are posted. Setting the alert bitmask all alerts

    When you get an alert, you can use typeid() or dynamic_cast<> to get more detailed information on exactly which type it is. i.e. what kind of error it is. You can also use a -dispatcher mechanism that's available in libtorrent.

    +dispatcher mechanism that's available in libtorrent.

    All alert types are defined in the <libtorrent/alert_types.hpp> header file.

    The alert class is the base class that specific messages are derived from. This is its synopsis:

    @@ -3858,8 +3922,8 @@ struct tracker_alert: torrent_alert };

    The specific alerts are:

    -
    -

    external_ip_alert

    +
    +

    external_ip_alert

    Whenever libtorrent learns about the machines external IP, this alert is generated. The external IP address can be acquired from the tracker (if it supports that) or from peers that supports the extension protocol. @@ -3872,14 +3936,14 @@ struct external_ip_alert: alert };

    -
    -

    listen_failed_alert

    +
    +

    listen_failed_alert

    This alert is generated when none of the ports, given in the port range, to -session can be opened for listening. This alert doesn't have any extra +session can be opened for listening. This alert doesn't have any extra data members.

    -
    -

    portmap_error_alert

    +
    +

    portmap_error_alert

    This alert is generated when a NAT router was successfully found but some part of the port mapping request failed. It contains a text message that may help the user figure out what is wrong. This alert is not generated in @@ -3887,7 +3951,7 @@ case it appears the client is not running on a NAT:ed network or if it appears there is no NAT router that can be remote controlled to add port mappings.

    mapping refers to the mapping index of the port map that failed, i.e. -the index returned from add_mapping.

    +the index returned from add_mapping.

    type is 0 for NAT-PMP and 1 for UPnP.

     struct portmap_error_alert: alert
    @@ -3898,14 +3962,14 @@ struct portmap_error_alert: alert
     };
     
    -
    -

    portmap_alert

    +
    +

    portmap_alert

    This alert is generated when a NAT router was successfully found and a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP capable router, this is typically generated once when mapping the TCP port and, if DHT is enabled, when the UDP port is mapped.

    mapping refers to the mapping index of the port map that failed, i.e. -the index returned from add_mapping.

    +the index returned from add_mapping.

    external_port is the external port allocated for the mapping.

    type is 0 for NAT-PMP and 1 for UPnP.

    @@ -3918,8 +3982,8 @@ struct portmap_alert: alert
     };
     
    -
    -

    file_error_alert

    +
    +

    file_error_alert

    If the storage fails to read or write files that it needs access to, this alert is generated and the torrent is paused.

    file is the path to the file that was accessed when the error occurred.

    @@ -3933,8 +3997,8 @@ struct file_error_alert: torrent_alert };
    -
    -

    tracker_announce_alert

    +
    +

    tracker_announce_alert

    This alert is generated each time a tracker announce is sent (or attempted to be sent). There are no extra data members in this alert. The url can be found in the base class however.

    @@ -3953,8 +4017,8 @@ struct tracker_announce_alert: tracker_alert
  • Stopped
  • -
    -

    tracker_error_alert

    +
    +

    tracker_error_alert

    This alert is generated on tracker time outs, premature disconnects, invalid response or a HTTP response other than "200 OK". From the alert you can get the handle to the torrent the tracker belongs to.

    @@ -3971,8 +4035,8 @@ struct tracker_error_alert: tracker_alert };
    -
    -

    tracker_reply_alert

    +
    +

    tracker_reply_alert

    This alert is only for informational purpose. It is generated when a tracker announce succeeds. It is generated regardless what kind of tracker was used, be it UDP, HTTP or the DHT.

    @@ -3986,8 +4050,8 @@ struct tracker_reply_alert: tracker_alert

    The num_peers tells how many peers were returned from the tracker. This is not necessarily all new peers, some of them may already be connected.

    -
    -

    dht_reply_alert

    +
    +

    dht_reply_alert

    This alert is generated each time the DHT receives peers from a node. num_peers is the number of peers we received in this packet. Typically these packets are received from multiple DHT nodes, and so the alerts are typically generated @@ -4000,8 +4064,8 @@ struct dht_reply_alert: tracker_alert };

    -
    -

    tracker_warning_alert

    +
    +

    tracker_warning_alert

    This alert is triggered if the tracker reply contains a warning field. Usually this means that the tracker announce was successful, but the tracker has a message to the client. The msg string in the alert contains the warning message from @@ -4014,8 +4078,8 @@ struct tracker_warning_alert: tracker_alert };

    -
    -

    scrape_reply_alert

    +
    +

    scrape_reply_alert

    This alert is generated when a scrape request succeeds. incomplete and complete is the data returned in the scrape response. These numbers may be -1 if the reponse was malformed.

    @@ -4028,8 +4092,8 @@ struct scrape_reply_alert: tracker_alert };
    -
    -

    scrape_failed_alert

    +
    +

    scrape_failed_alert

    If a scrape request fails, this alert is generated. This might be due to the tracker timing out, refusing connection or returning an http response code indicating an error. msg contains a message describing the error.

    @@ -4041,8 +4105,8 @@ struct scrape_failed_alert: tracker_alert };
    -
    -

    url_seed_alert

    +
    +

    url_seed_alert

    This alert is generated when a HTTP seed name lookup fails.

    It contains url to the HTTP seed that failed along with an error message.

    @@ -4053,8 +4117,8 @@ struct url_seed_alert: torrent_alert
     };
     
    -
    -

    hash_failed_alert

    +
    +

    hash_failed_alert

    This alert is generated when a finished piece fails its hash check. You can get the handle to the torrent which got the failed piece and the index of the piece itself from the alert.

    @@ -4065,8 +4129,8 @@ struct hash_failed_alert: torrent_alert
     };
     
    -
    -

    peer_ban_alert

    +
    +

    peer_ban_alert

    This alert is generated when a peer is banned because it has sent too many corrupt pieces to us. ip is the endpoint to the peer that was banned.

    @@ -4077,8 +4141,8 @@ struct peer_ban_alert: torrent_alert
     };
     
    -
    -

    peer_error_alert

    +
    +

    peer_error_alert

    This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer will be disconnected, but you get its ip address from the alert, to identify it.

    @@ -4090,8 +4154,8 @@ struct peer_error_alert: torrent_alert
     };
     
    -
    -

    invalid_request_alert

    +
    +

    invalid_request_alert

    This is a debug alert that is generated by an incoming invalid piece request. ìp is the address of the peer and the request is the actual incoming request from the peer.

    @@ -4125,15 +4189,15 @@ struct peer_request the index of the piece it want data from, start is the offset within the piece where the data should be read, and length is the amount of data it wants.

    -
    -

    torrent_finished_alert

    +
    +

    torrent_finished_alert

    This alert is generated when a torrent switches from being a downloader to a seed. It will only be generated once per torrent. It contains a torrent_handle to the torrent in question.

    There are no additional data members in this alert.

    -
    -

    performance_alert

    +
    +

    performance_alert

    This alert is generated when a limit is reached that might have a negative impact on upload or download rate performance.

    @@ -4151,23 +4215,23 @@ struct performance_alert: torrent_alert
     };
     
    -
    -

    metadata_failed_alert

    +
    +

    metadata_failed_alert

    This alert is generated when the metadata has been completely received and the info-hash failed to match it. i.e. the metadata that was received was corrupt. libtorrent will automatically retry to fetch it in this case. This is only relevant when running a torrent-less download, with the metadata extension provided by libtorrent.

    There are no additional data members in this alert.

    -
    -

    metadata_received_alert

    +
    +

    metadata_received_alert

    This alert is generated when the metadata has been completely received and the torrent can start downloading. It is not generated on torrents that are started with metadata, but only those that needs to download it from peers (when utilizing the libtorrent extension).

    There are no additional data members in this alert.

    -
    -

    fastresume_rejected_alert

    +
    +

    fastresume_rejected_alert

    This alert is generated when a fastresume file has been passed to add_torrent but the files on disk did not match the fastresume file. The string explains the reason why the resume file was rejected.

    @@ -4179,8 +4243,8 @@ struct fastresume_rejected_alert: torrent_alert };
    -
    -

    peer_blocked_alert

    +
    +

    peer_blocked_alert

    This alert is generated when a peer is blocked by the IP filter. The ip member is the address that was blocked.

    @@ -4191,8 +4255,8 @@ struct peer_blocked_alert: alert
     };
     
    -
    -

    storage_moved_alert

    +
    +

    storage_moved_alert

    The storage_moved_alert is generated when all the disk IO has completed and the files have been moved, as an effect of a call to torrent_handle::move_storage. This is useful to synchronize with the actual disk. The path member is the new path of @@ -4205,21 +4269,21 @@ struct storage_moved_alert: torrent_alert };

    -
    -

    torrent_paused_alert

    +
    +

    torrent_paused_alert

    This alert is generated as a response to a torrent_handle::pause request. It is generated once all disk IO is complete and the files in the torrent have been closed. This is useful for synchronizing with the disk.

    There are no additional data members in this alert.

    -
    -

    torrent_resumed_alert

    +
    +

    torrent_resumed_alert

    This alert is generated as a response to a torrent_handle::resume request. It is generated when a torrent goes from a paused state to an active state.

    There are no additional data members in this alert.

    -
    -

    save_resume_data_alert

    +
    +

    save_resume_data_alert

    This alert is generated as a response to a torrent_handle::save_resume_data request. It is generated once the disk IO thread is done writing the state for this torrent. The resume_data member points to the resume data.

    @@ -4231,8 +4295,8 @@ struct save_resume_data_alert: torrent_alert };
    -
    -

    save_resume_data_failed_alert

    +
    +

    save_resume_data_failed_alert

    This alert is generated instead of save_resume_data_alert if there was an error generating the resume data. msg describes what went wrong.

    @@ -4243,8 +4307,8 @@ struct save_resume_data_failed_alert: torrent_alert
     };
     
    -
    -

    dht_announce_alert

    +
    +

    dht_announce_alert

    This alert is generated when a DHT node announces to an info-hash on our DHT node. It belongs to the dht_notification category.

    @@ -4257,8 +4321,8 @@ struct dht_announce_alert: alert
     };
     
    -
    -

    dht_get_peers_alert

    +
    +

    dht_get_peers_alert

    This alert is generated when a DHT node sends a get_peers message to our DHT node. It belongs to the dht_notification category.

    @@ -4269,8 +4333,8 @@ struct dht_get_peers_alert: alert
     };
     
    -
    -

    dispatcher

    +
    +

    dispatcher

    The handle_alert class is defined in <libtorrent/alert.hpp>.

    Examples usage:

    @@ -4315,13 +4379,13 @@ parameters to select between more types. If the number of types are more than
     including <libtorrent/alert.hpp>.

    -
    -

    exceptions

    +
    +

    exceptions

    There are a number of exceptions that can be thrown from different places in libtorrent, here's a complete list with description.

    -
    -

    invalid_handle

    -

    This exception is thrown when querying information from a torrent_handle that hasn't +

    +

    invalid_handle

    +

    This exception is thrown when querying information from a torrent_handle that hasn't been initialized or that has become invalid.

     struct invalid_handle: std::exception
    @@ -4330,10 +4394,10 @@ struct invalid_handle: std::exception
     };
     
    -
    -

    duplicate_torrent

    -

    This is thrown by add_torrent() if the torrent already has been added to -the session. Since remove_torrent() is asynchronous, this exception may +

    +

    duplicate_torrent

    +

    This is thrown by add_torrent() if the torrent already has been added to +the session. Since remove_torrent() is asynchronous, this exception may be thrown if the torrent is removed and then immediately added again.

     struct duplicate_torrent: std::exception
    @@ -4342,8 +4406,8 @@ struct duplicate_torrent: std::exception
     };
     
    -
    -

    invalid_encoding

    +
    +

    invalid_encoding

    This is thrown by bdecode() if the input data is not a valid bencoding.

     struct invalid_encoding: std::exception
    @@ -4352,8 +4416,8 @@ struct invalid_encoding: std::exception
     };
     
    -
    -

    type_error

    +
    +

    type_error

    This is thrown from the accessors of entry if the data type of the entry doesn't match the type you want to extract from it.

    @@ -4363,8 +4427,8 @@ struct type_error: std::runtime_error
     };
     
    -
    -

    invalid_torrent_file

    +
    +

    invalid_torrent_file

    This exception is thrown from the constructor of torrent_info if the given bencoded information doesn't meet the requirements on what information has to be present in a torrent file.

    @@ -4375,8 +4439,8 @@ struct invalid_torrent_file: std::exception
     
    -
    -

    storage_interface

    +
    +

    storage_interface

    The storage interface is a pure virtual class that can be implemented to change the behavior of the actual file storage. The interface looks like this:

    @@ -4399,8 +4463,8 @@ struct storage_interface virtual ~storage_interface() {} }; -
    -

    initialize()

    +
    +

    initialize()

     bool initialize(bool allocate_files) = 0;
    @@ -4411,8 +4475,8 @@ will create directories and empty files at this point. If ftruncate all files to their target size.

    Returning true indicates an error occurred.

    -
    -

    read()

    +
    +

    read()

     int read(char* buf, int slot, int offset, int size) = 0;
    @@ -4422,8 +4486,8 @@ int read(char* buf, int slot, int offset, int size) = 0;
     and size number of bytes. The data is to be copied to buf.

    The return value is the number of bytes actually read.

    -
    -

    write()

    +
    +

    write()

     int write(const char* buf, int slot, int offset, int size) = 0;
    @@ -4433,8 +4497,8 @@ int write(const char* buf, int slot, int offset, int size) = 0;
     offset in that slot. The buffer size is size.

    The return value is the number of bytes actually written.

    -
    -

    move_storage()

    +
    +

    move_storage()

     bool move_storage(fs::path save_path) = 0;
    @@ -4446,8 +4510,8 @@ The default storage moves the single file or the directory of the torrent.

    release_files().

    Returning true indicates an error occurred.

    -
    -

    verify_resume_data()

    +
    +

    verify_resume_data()

     bool verify_resume_data(lazy_entry const& rd, std::string& error) = 0;
    @@ -4459,8 +4523,8 @@ not, set error to a d
     

    The default storage may compare file sizes and time stamps of the files.

    Returning true indicates an error occurred.

    -
    -

    write_resume_data()

    +
    +

    write_resume_data()

     bool write_resume_data(entry& rd) const = 0;
    @@ -4471,8 +4535,8 @@ storage, in rd. The d
     sizes.

    Returning true indicates an error occurred.

    -
    -

    move_slot()

    +
    +

    move_slot()

     bool move_slot(int src_slot, int dst_slot) = 0;
    @@ -4484,8 +4548,8 @@ the slot dst_slot. Th
     efficient than reading and writing the data.

    Returning true indicates an error occurred.

    -
    -

    swap_slots()

    +
    +

    swap_slots()

     bool swap_slots(int slot1, int slot2) = 0;
    @@ -4497,8 +4561,8 @@ slot and finally writing back the temporary slot's data

    This is only used in compact mode.

    Returning true indicates an error occurred.

    -
    -

    swap_slots3()

    +
    +

    swap_slots3()

     bool swap_slots3(int slot1, int slot2, int slot3) = 0;
    @@ -4510,8 +4574,8 @@ should be moved to slot1This is only used in compact mode.

    Returning true indicates an error occurred.

    -
    -

    hash_for_slot()

    +
    +

    hash_for_slot()

     sha1_hash hash_for_slot(int slot, partial_hash& h, int piece_size) = 0;
    @@ -4532,8 +4596,8 @@ struct partial_hash
     that is stored in the given slot.

    The function should return the hash of the piece stored in the slot.

    -
    -

    rename_file()

    +
    +

    rename_file()

     bool rename_file(int file, std::string const& new_name) = 0;
    @@ -4542,8 +4606,8 @@ bool rename_file(int file, std::string const& new_name) = 0;
     

    Rename file with index file to the thame new_name. If there is an error, true should be returned.

    -
    -

    release_files()

    +
    +

    release_files()

     bool release_files() = 0;
    @@ -4554,8 +4618,8 @@ belonging to this storage. The default implementation just calls
     file_pool::release_files(this).

    Returning true indicates an error occurred.

    -
    -

    delete_files()

    +
    +

    delete_files()

     bool delete_files() = 0;
    @@ -4565,8 +4629,8 @@ bool delete_files() = 0;
     

    Returning true indicates an error occurred.

    -
    -

    magnet links

    + -
    -

    queuing

    +
    +

    queuing

    libtorrent supports queuing. Which means it makes sure that a limited number of torrents are being downloaded at any given time, and once a torrent is completely downloaded, the next in line is started.

    Torrents that are auto managed are subject to the queuing and the active torrents limits. To make a torrent auto managed, set auto_managed to true when adding the -torrent (see add_torrent()).

    +torrent (see add_torrent()).

    The limits of the number of downloading and seeding torrents are controlled via -active_downloads, active_seeds and active_limit in session_settings. +active_downloads, active_seeds and active_limit in session_settings. These limits takes non auto managed torrents into account as well. If there are more non-auto managed torrents being downloaded than the active_downloads setting, any auto managed torrents will be queued until torrents are removed so @@ -4591,11 +4655,11 @@ that the number drops below the limit.

    The default values are 8 active downloads and 5 active seeds.

    At a regular interval, torrents are checked if there needs to be any re-ordering of which torrents are active and which are queued. This interval can be controlled via -auto_manage_interval in session_settings. It defaults to every 30 seconds.

    +auto_manage_interval in session_settings. It defaults to every 30 seconds.

    For queuing to work, resume data needs to be saved and restored for all torrents. -See save_resume_data().

    -
    -

    downloading

    +See save_resume_data().

    +
    +

    downloading

    Torrents that are currently being downloaded or incomplete (with bytes still to download) are queued. The torrents in the front of the queue are started to be actively downloaded and the rest are ordered with regards to their queue position. Any newly added torrent @@ -4606,35 +4670,35 @@ position in order to fill the gap.

    Lower queue position means closer to the front of the queue, and will be started sooner than torrents with higher queue positions.

    To query a torrent for its position in the queue, or change its position, see: -queue_position() queue_position_up() queue_position_down() queue_position_top() queue_position_bottom().

    +queue_position() queue_position_up() queue_position_down() queue_position_top() queue_position_bottom().

    -
    -

    seeding

    +
    +

    seeding

    Auto managed seeding torrents are rotated, so that all of them are allocated a fair amount of seeding. Torrents with fewer completed seed cycles are prioritized for seeding. A seed cycle is completed when a torrent meets either the share ratio limit (uploaded bytes / downloaded bytes), the share time ratio (time seeding / time downloaing) or seed time limit (time seeded).

    The relevant settings to control these limits are share_ratio_limit, -seed_time_ratio_limit and seed_time_limit in session_settings.

    +seed_time_ratio_limit and seed_time_limit in session_settings.

    -
    -

    fast resume

    +
    +

    fast resume

    The fast resume mechanism is a way to remember which pieces are downloaded and where they are put between sessions. You can generate fast resume data by -calling save_resume_data() on torrent_handle. You can +calling save_resume_data() on torrent_handle. You can then save this data to disk and use it when resuming the torrent. libtorrent will not check the piece hashes then, and rely on the information given in the fast-resume data. The fast-resume data also contains information about which blocks, in the unfinished pieces, were downloaded, so it will not have to start from scratch on the partially downloaded pieces.

    -

    To use the fast-resume data you simply give it to add_torrent(), and it +

    To use the fast-resume data you simply give it to add_torrent(), and it will skip the time consuming checks. It may have to do the checking anyway, if the fast-resume data is corrupt or doesn't fit the storage for that torrent, then it will not trust the fast-resume data and just do the checking.

    -
    -

    file format

    +
    +

    file format

    The file format is a bencoded dictionary containing the following fields:

    @@ -4743,8 +4807,8 @@ last resume data checkpoint.
    -
    -

    threads

    +
    +

    threads

    libtorrent starts 2 or 3 threads.

      @@ -4762,8 +4826,8 @@ non-blocking host name resolution to simulate non-blocking behavior.
    -
    -

    storage allocation

    +
    +

    storage allocation

    There are three modes in which storage (files on disk) are allocated in libtorrent.

    1. The traditional full allocation mode, where the entire files are filled up with @@ -4777,11 +4841,11 @@ pieces that have been downloaded.
    2. to where they belong. This is the recommended (and default) mode.

    The allocation mode is selected when a torrent is started. It is passed as an -argument to session::add_torrent() (see add_torrent()).

    +argument to session::add_torrent() (see add_torrent()).

    The decision to use full allocation or compact allocation typically depends on whether any files are filtered and if the filesystem supports sparse files.

    -
    -

    sparse allocation

    +
    +

    sparse allocation

    On filesystems that supports sparse files, this allocation mode will only use as much space as has been downloaded.

    @@ -4792,9 +4856,9 @@ as much space as has been downloaded.

    -
    -

    full allocation

    -

    When a torrent is started in full allocation mode, the disk-io thread (see threads) +

    +

    full allocation

    +

    When a torrent is started in full allocation mode, the disk-io thread (see threads) will make sure that the entire storage is allocated, and fill any gaps with zeros. This will be skipped if the filesystem supports sparse files or automatic zero filling. It will of course still check for existing pieces and fast resume data. The main @@ -4824,8 +4888,8 @@ out of date data, since pieces won't move around.

    -
    -

    compact allocation

    +
    +

    compact allocation

    The compact allocation will only allocate as much storage as it needs to keep the pieces downloaded so far. This means that pieces will be moved around to be placed at their final position in the files while downloading (to make sure the completed @@ -4873,9 +4937,9 @@ contain any piece), return that slot index.

    -
    -

    extensions

    -

    These extensions all operates within the extension protocol. The +

    +

    extensions

    +

    These extensions all operates within the extension protocol. The name of the extension is the name used in the extension-list packets, and the payload is the data in the extended message (not counting the length-prefix, message-id nor extension-id).

    @@ -4883,8 +4947,8 @@ length-prefix, message-id nor extension-id).

    handshake, it may be incompatible with future versions of the mainline bittorrent client.

    These are the extensions that are currently implemented.

    -
    -

    metadata from peers

    +
    +

    metadata from peers

    Extension name: "LT_metadata"

    The point with this extension is that you don't have to distribute the metadata (.torrent-file) separately. The metadata can be distributed @@ -5002,9 +5066,9 @@ doesn't have any metadata.

    -
    -

    HTTP seeding

    -

    The HTTP seed extension implements this specification.

    +
    +

    HTTP seeding

    +

    The HTTP seed extension implements this specification.

    The libtorrent implementation assumes that, if the URL ends with a slash ('/'), the filename should be appended to it in order to request pieces from that file. The way this works is that if the torrent is a single-file torrent, @@ -5013,8 +5077,8 @@ torrent's name '/' the file name is appended. This is the same directory structure that libtorrent will download torrents into.

    -
    -

    filename checks

    +
    +

    filename checks

    Boost.Filesystem will by default check all its paths to make sure they conform to filename requirements on many platforms. If you don't want this check, you can set it to either only check for native filesystem requirements or turn it off @@ -5022,20 +5086,31 @@ altogether. You can use:

     boost::filesystem::path::default_name_check(boost::filesystem::native);
     
    -

    for example. For more information, see the Boost.Filesystem docs.

    +

    for example. For more information, see the Boost.Filesystem docs.

    -
    -

    acknowledgments

    +
    +

    acknowledgments

    Written by Arvid Norberg. Copyright © 2003-2006

    Contributions by Magnus Jonsson, Daniel Wallin and Cory Nelson

    Lots of testing, suggestions and contributions by Massaroddel and Tianhao Qiu.

    Big thanks to Michael Wojciechowski and Peter Koeleman for making the autotools scripts.

    Thanks to Reimond Retz for bugfixes, suggestions and testing

    -

    Thanks to University of Umeå for providing development and test hardware.

    +

    Thanks to University of Umeå for providing development and test hardware.

    Project is hosted by sourceforge.

    -

    sf_logo

    +

    sf_logo

    +
    + +
    + +
    diff --git a/docs/projects.html b/docs/projects.html index c3392ad36..8fa4f22f1 100644 --- a/docs/projects.html +++ b/docs/projects.html @@ -5,10 +5,32 @@ projects using libtorrent + + +
    +
    +
    + +
    + +

    projects using libtorrent

    These are some of the public projects that uses libtorrent. If you want your @@ -199,6 +221,17 @@ among other things, bittorrent.

    +
    + +
    + +
    diff --git a/docs/template.txt b/docs/template.txt new file mode 100644 index 000000000..f886bb32d --- /dev/null +++ b/docs/template.txt @@ -0,0 +1,41 @@ +%(head_prefix)s +%(head)s + + +%(stylesheet)s + +%(body_prefix)s +
    +
    + +
    + +
    +%(body_pre_docinfo)s +%(docinfo)s +%(body)s +
    + +
    + + +%(body_suffix)s diff --git a/docs/udp_tracker_protocol.html b/docs/udp_tracker_protocol.html index ff5bea55c..3e34e9590 100644 --- a/docs/udp_tracker_protocol.html +++ b/docs/udp_tracker_protocol.html @@ -6,52 +6,74 @@ Bittorrent udp-tracker protocol extension + + +
    +
    +
    + +
    + +

    Bittorrent udp-tracker protocol extension

    - +
    Author:Arvid Norberg, arvid@rasterbar.com
    Arvid Norberg, arvid@rasterbar.com
    -
    -

    introduction

    +
    +

    introduction

    A tracker with the protocol "udp://" in its URI is supposed to be contacted using this protocol.

    This protocol is supported by -xbt-tracker.

    +xbt-tracker.

    For additional information and descritptions of the terminology used in this document, see -the protocol specification

    +the protocol specification

    All values are sent in network byte order (big endian). The sizes are specified with ANSI-C standard types.

    If no response to a request is received within 15 seconds, resend the request. If no reply has been received after 60 seconds, stop retrying.

    -
    -

    connecting

    +
    +

    connecting

    Client sends packet:

    @@ -100,7 +122,7 @@ identify the protocol. +If 3 (for error) see errors. @@ -120,8 +142,8 @@ anymore.
    action Describes the type of packet, in this case it should be 0, for connect. -If 3 (for error) see errors.
    int32_t transaction_id
    -
    -

    announcing

    +
    +

    announcing

    Client sends packet:

    @@ -144,7 +166,7 @@ establishing the connection. +See actions. @@ -209,7 +231,7 @@ in the reply. Use -1 for default. - +
    int32_t action Action. in this case, 1 for announce. -See actions.
    int32_t transaction_id
    uint16_t extensionsSee extensionsSee extensions
    @@ -231,8 +253,8 @@ in the reply. Use -1 for default. action The action this is a reply to. Should in this case be 1 for announce. -If 3 (for error) see errors. -See actions. +If 3 (for error) see errors. +See actions. int32_t transaction_id @@ -282,8 +304,8 @@ seeding.
    -
    -

    scraping

    +
    +

    scraping

    Client sends packet:

    @@ -306,7 +328,7 @@ establishing of the connection. +scrape. See actions. @@ -353,7 +375,7 @@ the MTU.

    +If 3 (for error) see errors. @@ -393,8 +415,8 @@ leechers.
    int32_t action The action, in this case, 2 for -scrape. See actions.
    int32_t transaction_id action The action, should in this case be 2 for scrape. -If 3 (for error) see errors.
    int32_t transaction_id
    -
    -

    errors

    +
    +

    errors

    In case of a tracker error,

    server replies packet:

    @@ -413,7 +435,7 @@ leechers. +See actions. @@ -428,8 +450,8 @@ describing the error.
    int32_t action The action, in this case 3, for error. -See actions.
    int32_t transaction_id
    -
    -

    actions

    +
    +

    actions

    The action fields has the following encoding:

      @@ -440,17 +462,17 @@ describing the error.
    -
    -

    extensions

    +
    +

    extensions

    The extensions field is a bitmask. The following bits are assigned:

    -
    -

    authentication

    +
    +

    authentication

    The packet will have an authentication part appended to it. It has the following format:

    @@ -489,10 +511,21 @@ from the 20 bytes hash calculated.
    -
    -

    credits

    +
    +

    credits

    Protocol designed by Olaf van der Spek

    +
    + +
    + +