1 ============================
2 libtorrent API Documentation
3 ============================
5 :Author: Arvid Norberg, arvid@rasterbar.com
8 .. contents:: Table of contents
15 The interface of libtorrent consists of a few classes. The main class is
16 the ``session``, it contains the main loop that serves all torrents.
18 The basic usage is as follows:
21 * start DHT, LSD, UPnP, NAT-PMP etc (see `start_dht() stop_dht() set_dht_settings() dht_state()`_
22 `start_lsd() stop_lsd()`_, `start_upnp() stop_upnp()`_ and `start_natpmp() stop_natpmp()`_)
23 * parse .torrent-files and add them to the session (see `bdecode() bencode()`_ and `add_torrent()`_)
24 * main loop (see session_)
26 * query the torrent_handles for progress (see torrent_handle_)
27 * query the session for information
28 * add and remove torrents from the session at run-time
30 * save resume data for all torrent_handles (optional, see
31 `save_resume_data()`_)
32 * destruct session object
34 Each class and function is described in this manual.
36 For a description on how to create torrent files, see make_torrent_.
38 .. _make_torrent: make_torrent.html
43 There are a few typedefs in the ``libtorrent`` namespace which pulls
44 in network types from the ``asio`` namespace. These are::
46 typedef asio::ip::address address;
47 typedef asio::ip::address_v4 address_v4;
48 typedef asio::ip::address_v6 address_v6;
52 These are declared in the ``<libtorrent/socket.hpp>`` header.
54 The ``using`` statements will give easy access to::
59 Which are the endpoint types used in libtorrent. An endpoint is an address
60 with an associated port.
62 For documentation on these types, please refer to the `asio documentation`_.
64 .. _`asio documentation`: http://asio.sourceforge.net/asio-0.3.8/doc/asio/reference.html
69 The ``session`` class has the following synopsis::
71 class session: public boost::noncopyable
74 session(fingerprint const& print
75 = libtorrent::fingerprint(
79 fingerprint const& print
80 , std::pair<int, int> listen_port_range
81 , char const* listen_interface = 0);
83 torrent_handle add_torrent(add_torrent_params const& params);
87 bool is_paused() const;
89 session_proxy abort();
97 void remove_torrent(torrent_handle const& h, int options = none);
98 torrent_handle find_torrent(sha_hash const& ih);
99 std::vector<torrent_handle> get_torrents() const;
101 void set_settings(session_settings const& settings);
102 void set_pe_settings(pe_settings const& settings);
104 void set_upload_rate_limit(int bytes_per_second);
105 int upload_rate_limit() const;
106 void set_download_rate_limit(int bytes_per_second);
107 int download_rate_limit() const;
108 void set_max_uploads(int limit);
109 void set_max_connections(int limit);
110 void set_max_half_open_connections(int limit);
111 int max_half_open_connections() const;
113 void set_peer_proxy(proxy_settings const& s);
114 void set_web_seed_proxy(proxy_settings const& s);
115 void set_tracker_proxy(proxy_settings const& s);
117 proxy_settings const& peer_proxy() const;
118 proxy_settings const& web_seed_proxy() const;
119 proxy_settings const& tracker_proxy() const;
121 int num_uploads() const;
122 int num_connections() const;
124 bool load_asnum_db(char const* file);
125 bool load_country_db(char const* file);
126 int as_for_ip(address const& adr);
128 void load_state(entry const& ses_state);
131 void set_ip_filter(ip_filter const& f);
133 session_status status() const;
134 cache_status get_cache_status() const;
136 bool is_listening() const;
137 unsigned short listen_port() const;
139 std::pair<int, int> const& port_range
140 , char const* interface = 0);
142 std::auto_ptr<alert> pop_alert();
143 alert const* wait_for_alert(time_duration max_wait);
144 void set_alert_mask(int m);
146 void add_extension(boost::function<
147 boost::shared_ptr<torrent_plugin>(torrent*)> ext);
151 void set_dht_settings(
152 dht_settings const& settings);
153 entry dht_state() const;
154 void add_dht_node(std::pair<std::string
156 void add_dht_router(std::pair<std::string
165 natpmp* start_natpmp();
169 Once it's created, the session object will spawn the main thread that will do all the work.
170 The main thread will be idle as long it doesn't have any torrents to participate in.
177 session(fingerprint const& print
178 = libtorrent::fingerprint("LT", 0, 1, 0, 0));
179 session(fingerprint const& print
180 , std::pair<int, int> listen_port_range
181 , char const* listen_interface = 0);
183 If the fingerprint in the first overload is omited, the client will get a default
184 fingerprint stating the version of libtorrent. The fingerprint is a short string that will be
185 used in the peer-id to identify the client and the client's version. For more details see the
186 fingerprint_ class. The constructor that only takes a fingerprint will not open a
187 listen port for the session, to get it running you'll have to call ``session::listen_on()``.
188 The other constructor, that takes a port range and an interface as well as the fingerprint
189 will automatically try to listen on a port on the given interface. For more information about
190 the parameters, see ``listen_on()`` function.
195 The destructor of session will notify all trackers that our torrents have been shut down.
196 If some trackers are down, they will time out. All this before the destructor of session
197 returns. So, it's advised that any kind of interface (such as windows) are closed before
198 destructing the session object. Because it can take a few second for it to finish. The
199 timeout can be set with ``set_settings()``.
201 pause() resume() is_paused()
202 ----------------------------
207 bool is_paused() const;
209 Pausing the session has the same effect as pausing every torrent in it. Resuming
210 will restore the torrents to their previous paused state. i.e. the session pause
211 state is separate from the torrent pause state. A torrent is inactive if it is
212 paused or if the session is paused.
219 session_proxy abort();
221 In case you want to destruct the session asynchrounously, you can request a session
222 destruction proxy. If you don't do this, the destructor of the session object will
223 block while the trackers are contacted. If you keep one ``session_proxy`` to the
224 session when destructing it, the destructor will not block, but start to close down
225 the session, the destructor of the proxy will then synchronize the threads. So, the
226 destruction of the session is performed from the ``session`` destructor call until the
227 ``session_proxy`` destructor call. The ``session_proxy`` does not have any operations
228 on it (since the session is being closed down, no operations are allowed on it). The
229 only valid operation is calling the destructor::
244 typedef storage_interface* (&storage_constructor_type)(
245 file_storage const&, fs::path const&, file_pool&);
247 struct add_torrent_params
249 add_torrent_params(storage_constructor_type s);
251 boost::intrusive_ptr<torrent_info> ti;
252 char const* tracker_url;
256 std::vector<char>* resume_data;
257 storage_mode_t storage_mode;
260 bool duplicate_is_error;
261 storage_constructor_type storage;
265 torrent_handle add_torrent(add_torrent_params const& params);
267 You add torrents through the ``add_torrent()`` function where you give an
268 object with all the parameters.
270 The only mandatory parameter is ``save_path`` which is the directory where you
271 want the files to be saved. You also need to specify either the ``ti`` (the
272 torrent file) or ``info_hash`` (the info hash of the torrent). If you specify the
273 info-hash, the torrent file will be downloaded from peers, which requires them to
274 support the metadata extension. For the metadata extension to work, libtorrent must
275 be built with extensions enabled (``TORRENT_DISABLE_EXTENSIONS`` must not be
276 defined). It also takes an optional ``name`` argument. This may be 0 in case no
277 name should be assigned to the torrent. In case it's not 0, the name is used for
278 the torrent as long as it doesn't have metadata. See ``torrent_handle::name``.
280 If the torrent doesn't have a tracker, but relies on the DHT to find peers, the
281 ``tracker_url`` can be 0, otherwise you might specify a tracker url that tracks this
284 If the torrent you are trying to add already exists in the session (is either queued
285 for checking, being checked or downloading) ``add_torrent()`` will throw
286 duplicate_torrent_ which derives from ``std::exception`` unless ``duplicate_is_error``
287 is set to false. In that case, ``add_torrent`` will return the handle to the existing
290 The optional parameter, ``resume_data`` can be given if up to date fast-resume data
291 is available. The fast-resume data can be acquired from a running torrent by calling
292 `save_resume_data()`_ on `torrent_handle`_. See `fast resume`_. The ``vector`` that is
293 passed in will be swapped into the running torrent instance with ``std::vector::swap()``.
295 The ``storage_mode`` parameter refers to the layout of the storage for this torrent.
296 There are 3 different modes:
299 All pieces will be written to the place where they belong and sparse files
300 will be used. This is the recommended, and default mode.
302 storage_mode_allocate
303 All pieces will be allocated, zeroes will be written to the files, before
304 the data is downloaded and written to the file. This might be useful for
305 filesystems that don't support sparse files.
308 The storage will grow as more pieces are downloaded, and pieces
309 are rearranged to finally be in their correct places once the entire torrent has been
312 For more information, see `storage allocation`_.
314 ``paused`` is a boolean that specifies whether or not the torrent is to be started in
315 a paused state. I.e. it won't connect to the tracker or any of the peers until it's
316 resumed. This is typically a good way of avoiding race conditions when setting
317 configuration options on torrents before starting them.
319 If ``auto_managed`` is true, this torrent will be queued, started and seeded
320 automatically by libtorrent. When this is set, the torrent should also be started
321 as paused. The default queue order is the order the torrents were added. They
322 are all downloaded in that order. For more details, see queuing_.
324 ``storage`` can be used to customize how the data is stored. The default
325 storage will simply write the data to the files it belongs to, but it could be
326 overridden to save everything to a single file at a specific location or encrypt the
327 content on disk for instance. For more information about the ``storage_interface``
328 that needs to be implemented for a custom storage, see `storage_interface`_.
330 The ``userdata`` parameter is optional and will be passed on to the extension
331 constructor functions, if any (see `add_extension()`_).
333 The torrent_handle_ returned by ``add_torrent()`` can be used to retrieve information
334 about the torrent's progress, its peers etc. It is also used to abort a torrent.
342 void remove_torrent(torrent_handle const& h, int options = none);
344 ``remove_torrent()`` will close all peer connections associated with the torrent and tell
345 the tracker that we've stopped participating in the swarm. The optional second argument
346 ``options`` can be used to delete all the files downloaded by this torrent. To do this, pass
347 in the value ``session::delete_files``. The removal of the torrent is asyncronous, there is
348 no guarantee that adding the same torrent immediately after it was removed will not throw
349 a duplicate_torrent_ exception.
351 find_torrent() get_torrents()
352 -----------------------------
356 torrent_handle find_torrent(sha_hash const& ih);
357 std::vector<torrent_handle> get_torrents() const;
359 ``find_torrent()`` looks for a torrent with the given info-hash. In case there
360 is such a torrent in the session, a torrent_handle to that torrent is returned.
361 In case the torrent cannot be found, an invalid torrent_handle is returned.
363 See ``torrent_handle::is_valid()`` to know if the torrent was found or not.
365 ``get_torrents()`` returns a vector of torrent_handles to all the torrents
366 currently in the session.
369 set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()
370 -------------------------------------------------------------------------------------------
374 void set_upload_rate_limit(int bytes_per_second);
375 void set_download_rate_limit(int bytes_per_second);
376 int upload_rate_limit() const;
377 int download_rate_limit() const;
379 ``set_upload_rate_limit()`` set the maximum number of bytes allowed to be
380 sent to peers per second. This bandwidth is distributed among all the peers. If
381 you don't want to limit upload rate, you can set this to -1 (the default).
382 ``set_download_rate_limit()`` works the same way but for download rate instead
384 ``download_rate_limit()`` and ``upload_rate_limit()`` returns the previously
388 set_max_uploads() set_max_connections()
389 ---------------------------------------
393 void set_max_uploads(int limit);
394 void set_max_connections(int limit);
396 These functions will set a global limit on the number of unchoked peers (uploads)
397 and the number of connections opened. The number of connections is set to a hard
398 minimum of at least two connections per torrent, so if you set a too low
399 connections limit, and open too many torrents, the limit will not be met. The
400 number of uploads is at least one per torrent.
403 num_uploads() num_connections()
404 -------------------------------
408 int num_uploads() const;
409 int num_connections() const;
411 Returns the number of currently unchoked peers and the number of connections
412 (including half-open ones) respectively.
415 set_max_half_open_connections() max_half_open_connections()
416 -----------------------------------------------------------
420 void set_max_half_open_connections(int limit);
421 int max_half_open_connections() const;
423 Sets the maximum number of half-open connections libtorrent will have when
424 connecting to peers. A half-open connection is one where connect() has been
425 called, but the connection still hasn't been established (nor failed). Windows
426 XP Service Pack 2 sets a default, system wide, limit of the number of half-open
427 connections to 10. So, this limit can be used to work nicer together with
428 other network applications on that system. The default is to have no limit,
429 and passing -1 as the limit, means to have no limit. When limiting the number
430 of simultaneous connection attempts, peers will be put in a queue waiting for
431 their turn to get connected.
433 ``max_half_open_connections()`` returns the set limit. This limit defaults
436 load_asnum_db() load_country_db() int as_for_ip()
437 -------------------------------------------------
441 bool load_asnum_db(char const* file);
442 bool load_country_db(char const* file);
443 int as_for_ip(address const& adr);
445 These functions are not available if ``TORRENT_DISABLE_GEO_IP`` is defined. They
446 expects a path to the `MaxMind ASN database`_ and `MaxMind GeoIP database`_
447 respectively. This will be used to look up which AS and country peers belong to.
449 ``as_for_ip`` returns the AS number for the IP address specified. If the IP is not
450 in the database or the ASN database is not loaded, 0 is returned.
452 .. _`MaxMind ASN database`: http://www.maxmind.com/app/asnum
453 .. _`MaxMind GeoIP database`: http://www.maxmind.com/app/geolitecountry
460 void load_state(entry const& ses_state);
463 These functions loads and save session state. Currently, the only state
464 that's stored is peak download rates for ASes. This map is used to
465 determine which order to connect to peers.
472 void set_ip_filter(ip_filter const& filter);
474 Sets a filter that will be used to reject and accept incoming as well as outgoing
475 connections based on their originating ip address. The default filter will allow
476 connections to any ip address. To build a set of rules for which addresses are
477 accepted and not, see ip_filter_.
479 Each time a peer is blocked because of the IP filter, a peer_blocked_alert_ is
488 session_status status() const;
490 ``status()`` returns session wide-statistics and status. The ``session_status``
491 struct has the following members::
493 struct session_status
495 bool has_incoming_connections;
500 float payload_upload_rate;
501 float payload_download_rate;
503 size_type total_download;
504 size_type total_upload;
506 size_type total_redundant_bytes;
507 size_type total_failed_bytes;
509 size_type total_payload_download;
510 size_type total_payload_upload;
514 int allowed_upload_slots;
519 int dht_global_nodes;
522 ``has_incoming_connections`` is false as long as no incoming connections have been
523 established on the listening socket. Every time you change the listen port, this will
526 ``upload_rate``, ``download_rate``, ``payload_download_rate`` and ``payload_upload_rate``
527 are the total download and upload rates accumulated from all torrents. The payload
528 versions is the payload download only.
530 ``total_download`` and ``total_upload`` are the total number of bytes downloaded and
531 uploaded to and from all torrents. ``total_payload_download`` and ``total_payload_upload``
532 are the same thing but where only the payload is considered.
534 ``total_redundant_bytes`` is the number of bytes that has been received more than once.
535 This can happen if a request from a peer times out and is requested from a different
536 peer, and then received again from the first one. To make this lower, increase the
537 ``request_timeout`` and the ``piece_timeout`` in the session settings.
539 ``total_failed_bytes`` is the number of bytes that was downloaded which later failed
542 ``num_peers`` is the total number of peer connections this session has. This includes
543 incoming connections that still hasn't sent their handshake or outgoing connections
544 that still hasn't completed the TCP connection. This number may be slightly higher
545 than the sum of all peers of all torrents because the incoming connections may not
546 be assigned a torrent yet.
548 ``num_unchoked`` is the current number of unchoked peers.
549 ``allowed_upload_slots`` is the current allowed number of unchoked peers.
551 ``dht_nodes``, ``dht_cache_nodes`` and ``dht_torrents`` are only available when
552 built with DHT support. They are all set to 0 if the DHT isn't running. When
553 the DHT is running, ``dht_nodes`` is set to the number of nodes in the routing
554 table. This number only includes *active* nodes, not cache nodes. The
555 ``dht_cache_nodes`` is set to the number of nodes in the node cache. These nodes
556 are used to replace the regular nodes in the routing table in case any of them
557 becomes unresponsive.
559 ``dht_torrents`` are the number of torrents tracked by the DHT at the moment.
561 ``dht_global_nodes`` is an estimation of the total number of nodes in the DHT
569 cache_status get_cache_status() const;
571 Returns status of the disk cache for this session.
577 size_type blocks_written;
579 size_type blocks_read;
580 size_type blocks_read_hit;
586 ``blocks_written`` is the total number of 16 KiB blocks written to disk
587 since this session was started.
589 ``writes`` is the total number of write operations performed since this
592 The ratio (``blocks_written`` - ``writes``) / ``blocks_written`` represents
593 the number of saved write operations per total write operations. i.e. a kind
594 of cache hit ratio for the write cahe.
596 ``blocks_read`` is the number of blocks that were requested from the
597 bittorrent engine (from peers), that were served from disk or cache.
599 ``blocks_read_hit`` is the number of blocks that were served from cache.
601 The ratio ``blocks_read_hit`` / ``blocks_read`` is the cache hit ratio
604 ``cache_size`` is the number of 16 KiB blocks currently in the disk cache.
605 This includes both read and write cache.
607 ``read_cache_size`` is the number of 16KiB blocks in the read cache.
614 void get_cache_info(sha1_hash const& ih
615 , std::vector<cached_piece_info>& ret) const;
617 ``get_cache_info()`` fills out the supplied vector with information for
618 each piece that is currently in the disk cache for the torrent with the
619 specified info-hash (``ih``).
623 struct cached_piece_info
626 std::vector<bool> blocks;
628 enum kind_t { read_cache = 0, write_cache = 1 };
632 ``piece`` is the piece index for this cache entry.
634 ``blocks`` has one entry for each block in this piece. ``true`` represents
635 the data for that block being in the disk cache and ``false`` means it's not.
637 ``last_use`` is the time when a block was last written to this piece. The older
638 a piece is, the more likely it is to be flushed to disk.
640 ``kind`` specifies if this piece is part of the read cache or the write cache.
642 is_listening() listen_port() listen_on()
643 ----------------------------------------
647 bool is_listening() const;
648 unsigned short listen_port() const;
650 std::pair<int, int> const& port_range
651 , char const* interface = 0);
653 ``is_listening()`` will tell you whether or not the session has successfully
654 opened a listening port. If it hasn't, this function will return false, and
655 then you can use ``listen_on()`` to make another try.
657 ``listen_port()`` returns the port we ended up listening on. Since you just pass
658 a port-range to the constructor and to ``listen_on()``, to know which port it
659 ended up using, you have to ask the session using this function.
661 ``listen_on()`` will change the listen port and/or the listen interface. If the
662 session is already listening on a port, this socket will be closed and a new socket
663 will be opened with these new settings. The port range is the ports it will try
664 to listen on, if the first port fails, it will continue trying the next port within
665 the range and so on. The interface parameter can be left as 0, in that case the
666 os will decide which interface to listen on, otherwise it should be the ip-address
667 of the interface you want the listener socket bound to. ``listen_on()`` returns true
668 if it managed to open the socket, and false if it failed. If it fails, it will also
669 generate an appropriate alert (listen_failed_alert_).
671 The interface parameter can also be a hostname that will resolve to the device you
674 If you're also starting the DHT, it is a good idea to do that after you've called
675 ``listen_on()``, since the default listen port for the DHT is the same as the tcp
676 listen socket. If you start the DHT first, it will assume the tcp port is free and
677 open the udp socket on that port, then later, when ``listen_on()`` is called, it
678 may turn out that the tcp port is in use. That results in the DHT and the bittorrent
679 socket listening on different ports. If the DHT is active when ``listen_on`` is
680 called, the udp port will be rebound to the new port, if it was configured to use
681 the same port as the tcp socket, and if the listen_on call failed to bind to the
682 same port that the udp uses.
684 The reason why it's a good idea to run the DHT and the bittorrent socket on the same
685 port is because that is an assumption that may be used to increase performance. One
686 way to accelerate the connecting of peers on windows may be to first ping all peers
687 with a DHT ping packet, and connect to those that responds first. On windows one
688 can only connect to a few peers at a time because of a built in limitation (in XP
691 pop_alert() set_alert_mask() wait_for_alert()
692 ---------------------------------------------
696 std::auto_ptr<alert> pop_alert();
697 alert const* wait_for_alert(time_duration max_wait);
698 void set_alert_mask(int m);
700 ``pop_alert()`` is used to ask the session if any errors or events has occurred. With
701 ``set_alert_mask()`` you can filter which alerts to receive through ``pop_alert()``.
702 For information about the alert categories, see alerts_.
704 ``wait_for_alert`` blocks until an alert is available, or for no more than ``max_wait``
705 time. If ``wait_for_alert`` returns because of the time-out, and no alerts are available,
706 it returns 0. If at least one alert was generated, a pointer to that alert is returned.
707 The alert is not popped, any subsequent calls to ``wait_for_alert`` will return the
708 same pointer until the alert is popped by calling ``pop_alert``. This is useful for
709 leaving any alert dispatching mechanism independent of this blocking call, the dispatcher
710 can be called and it can pop the alert independently.
718 void add_extension(boost::function<
719 boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext);
721 This function adds an extension to this session. The argument is a function
722 object that is called with a ``torrent*`` and which should return a
723 ``boost::shared_ptr<torrent_plugin>``. To write custom plugins, see
724 `libtorrent plugins`_. The main plugins implemented in libtorrent are:
727 Allows peers to download the metadata (.torren files) from the swarm
728 directly. Makes it possible to join a swarm with just a tracker and
733 #include <libtorrent/extensions/metadata_transfer.hpp>
734 ses.add_extension(&libtorrent::create_metadata_plugin);
737 Same as ``metadata extension`` but compatible with uTorrent.
741 #include <libtorrent/extensions/ut_metadata.hpp>
742 ses.add_extension(&libtorrent::create_ut_metadata_plugin);
744 uTorrent peer exchange
745 Exchanges peers between clients.
749 #include <libtorrent/extensions/ut_pex.hpp>
750 ses.add_extension(&libtorrent::create_ut_pex_plugin);
753 A plugin that, with a small overhead, can ban peers
754 that sends bad data with very high accuracy. Should
755 eliminate most problems on poisoned torrents.
759 #include <libtorrent/extensions/smart_ban.hpp>
760 ses.add_extension(&libtorrent::create_smart_ban_plugin);
763 .. _`libtorrent plugins`: libtorrent_plugins.html
765 set_settings() set_pe_settings()
766 --------------------------------
770 void set_settings(session_settings const& settings);
771 void set_pe_settings(pe_settings const& settings);
773 Sets the session settings and the packet encryption settings respectively.
774 See session_settings_ and pe_settings_ for more information on available
778 set_peer_proxy() set_web_seed_proxy() set_tracker_proxy() set_dht_proxy()
779 -------------------------------------------------------------------------
783 void set_peer_proxy(proxy_settings const& s);
784 void set_web_seed_proxy(proxy_settings const& s);
785 void set_tracker_proxy(proxy_settings const& s);
786 void set_dht_proxy(proxy_settings const& s);
788 The ``set_dht_proxy`` is not available when DHT is disabled. These functions
789 sets the proxy settings for different kinds of connections, bittorrent peers,
790 web seeds, trackers and the DHT traffic.
792 ``set_peer_proxy`` affects regular bittorrent peers. ``set_web_seed_proxy``
793 affects only web seeds. see `HTTP seeding`_.
795 ``set_tracker_proxy`` only affects HTTP tracker connections (UDP tracker
796 connections are affected if the given proxy supports UDP, e.g. SOCKS5).
798 ``set_dht_proxy`` affects the DHT messages. Since they are sent over UDP,
799 it only has any effect if the proxy supports UDP.
801 For more information on what settings are available for proxies, see
805 peer_proxy() web_seed_proxy() tracker_proxy() dht_proxy()
806 ---------------------------------------------------------
810 proxy_settings const& peer_proxy() const;
811 proxy_settings const& web_seed_proxy() const;
812 proxy_settings const& tracker_proxy() const;
813 proxy_settings const& dht_proxy() const;
815 These functions returns references to their respective current settings.
817 The ``dht_proxy`` is not available when DHT is disabled.
820 start_dht() stop_dht() set_dht_settings() dht_state()
821 -----------------------------------------------------
825 void start_dht(entry const& startup_state);
827 void set_dht_settings(dht_settings const& settings);
828 entry dht_state() const;
830 These functions are not available in case ``TORRENT_DISABLE_DHT`` is
831 defined. ``start_dht`` starts the dht node and makes the trackerless service
832 available to torrents. The startup state is optional and can contain nodes
833 and the node id from the previous session. The dht node state is a bencoded
834 dictionary with the following entries:
837 A list of strings, where each string is a node endpoint encoded in binary. If
838 the string is 6 bytes long, it is an IPv4 address of 4 bytes, encoded in
839 network byte order (big endian), followed by a 2 byte port number (also
840 network byte order). If the string is 18 bytes long, it is 16 bytes of IPv6
841 address followed by a 2 bytes port number (also network byte order).
844 The node id written as a readable string as a hexadecimal number.
846 ``dht_state`` will return the current state of the dht node, this can be used
847 to start up the node again, passing this entry to ``start_dht``. It is a good
848 idea to save this to disk when the session is closed, and read it up again
851 If the port the DHT is supposed to listen on is already in use, and exception
852 is thrown, ``asio::error``.
854 ``stop_dht`` stops the dht node.
856 ``add_dht_node`` adds a node to the routing table. This can be used if your
857 client has its own source of bootstrapping nodes.
859 ``set_dht_settings`` sets some parameters availavle to the dht node. The
860 struct has the following members::
865 int search_branching;
870 ``max_peers_reply`` is the maximum number of peers the node will send in
871 response to a ``get_peers`` message from another node.
873 ``search_branching`` is the number of concurrent search request the node will
874 send when announcing and refreshing the routing table. This parameter is
875 called alpha in the kademlia paper.
877 ``service_port`` is the udp port the node will listen to. This will default
878 to 0, which means the udp listen port will be the same as the tcp listen
879 port. This is in general a good idea, since some NAT implementations
880 reserves the udp port for any mapped tcp port, and vice versa. NAT-PMP
881 guarantees this for example.
883 ``max_fail_count`` is the maximum number of failed tries to contact a node
884 before it is removed from the routing table. If there are known working nodes
885 that are ready to replace a failing node, it will be replaced immediately,
886 this limit is only used to clear out nodes that don't have any node that can
890 add_dht_node() add_dht_router()
891 -------------------------------
895 void add_dht_node(std::pair<std::string, int> const& node);
896 void add_dht_router(std::pair<std::string, int> const& node);
898 ``add_dht_node`` takes a host name and port pair. That endpoint will be
899 pinged, and if a valid DHT reply is received, the node will be added to
902 ``add_dht_router`` adds the given endpoint to a list of DHT router nodes.
903 If a search is ever made while the routing table is empty, those nodes will
904 be used as backups. Nodes in the router node list will also never be added
905 to the regular routing table, which effectively means they are only used
906 for bootstrapping, to keep the load off them.
908 An example routing node that you could typically add is
909 ``router.bittorrent.com``.
912 start_lsd() stop_lsd()
913 ----------------------
920 Starts and stops Local Service Discovery. This service will broadcast
921 the infohashes of all the non-private torrents on the local network to
922 look for peers on the same swarm within multicast reach.
924 It is turned off by default.
926 start_upnp() stop_upnp()
927 ------------------------
934 Starts and stops the UPnP service. When started, the listen port and the DHT
935 port are attempted to be forwarded on local UPnP router devices.
937 The upnp object returned by ``start_upnp()`` can be used to add and remove
938 arbitrary port mappings. Mapping status is returned through the
939 portmap_alert_ and the portmap_error_alert_. The object will be valid until
940 ``stop_upnp()`` is called. See `UPnP and NAT-PMP`_.
942 It is off by default.
944 start_natpmp() stop_natpmp()
945 ----------------------------
949 natpmp* start_natpmp();
952 Starts and stops the NAT-PMP service. When started, the listen port and the DHT
953 port are attempted to be forwarded on the router through NAT-PMP.
955 The natpmp object returned by ``start_natpmp()`` can be used to add and remove
956 arbitrary port mappings. Mapping status is returned through the
957 portmap_alert_ and the portmap_error_alert_. The object will be valid until
958 ``stop_natpmp()`` is called. See `UPnP and NAT-PMP`_.
960 It is off by default.
966 The ``entry`` class represents one node in a bencoded hierarchy. It works as a
967 variant type, it can be either a list, a dictionary (``std::map``), an integer
968 or a string. This is its synopsis::
974 typedef std::map<std::string, entry> dictionary_type;
975 typedef std::string string_type;
976 typedef std::list<entry> list_type;
977 typedef size_type integer_type;
988 data_type type() const;
990 entry(dictionary_type const&);
991 entry(string_type const&);
992 entry(list_type const&);
993 entry(integer_type const&);
997 entry(entry const& e);
1000 void operator=(entry const& e);
1001 void operator=(dictionary_type const&);
1002 void operator=(string_type const&);
1003 void operator=(list_type const&);
1004 void operator=(integer_type const&);
1006 integer_type& integer();
1007 integer_type const& integer() const;
1008 string_type& string();
1009 string_type const& string() const;
1011 list_type const& list() const;
1012 dictionary_type& dict();
1013 dictionary_type const& dict() const;
1015 // these functions requires that the entry
1016 // is a dictionary, otherwise they will throw
1017 entry& operator[](char const* key);
1018 entry& operator[](std::string const& key);
1019 entry const& operator[](char const* key) const;
1020 entry const& operator[](std::string const& key) const;
1021 entry* find_key(char const* key);
1022 entry const* find_key(char const* key) const;
1024 void print(std::ostream& os, int indent = 0) const;
1027 *TODO: finish documentation of entry.*
1029 integer() string() list() dict() type()
1030 ---------------------------------------
1034 integer_type& integer();
1035 integer_type const& integer() const;
1036 string_type& string();
1037 string_type const& string() const;
1039 list_type const& list() const;
1040 dictionary_type& dict();
1041 dictionary_type const& dict() const;
1043 The ``integer()``, ``string()``, ``list()`` and ``dict()`` functions
1044 are accessors that return the respective type. If the ``entry`` object isn't of the
1045 type you request, the accessor will throw type_error_ (which derives from
1046 ``std::runtime_error``). You can ask an ``entry`` for its type through the
1047 ``type()`` function.
1049 The ``print()`` function is there for debug purposes only.
1051 If you want to create an ``entry`` you give it the type you want it to have in its
1052 constructor, and then use one of the non-const accessors to get a reference which you then
1053 can assign the value you want it to have.
1055 The typical code to get info from a torrent file will then look like this::
1060 // throws if this is not a dictionary
1061 entry::dictionary_type const& dict = torrent_file.dict();
1062 entry::dictionary_type::const_iterator i;
1063 i = dict.find("announce");
1064 if (i != dict.end())
1066 std::string tracker_url = i->second.string();
1067 std::cout << tracker_url << "\n";
1071 The following code is equivalent, but a little bit shorter::
1076 // throws if this is not a dictionary
1077 if (entry* i = torrent_file.find_key("announce"))
1079 std::string tracker_url = i->string();
1080 std::cout << tracker_url << "\n";
1084 To make it easier to extract information from a torrent file, the class torrent_info_
1093 entry& operator[](char const* key);
1094 entry& operator[](std::string const& key);
1095 entry const& operator[](char const* key) const;
1096 entry const& operator[](std::string const& key) const;
1098 All of these functions requires the entry to be a dictionary, if it isn't they
1099 will throw ``libtorrent::type_error``.
1101 The non-const versions of the ``operator[]`` will return a reference to either
1102 the existing element at the given key or, if there is no element with the
1103 given key, a reference to a newly inserted element at that key.
1105 The const version of ``operator[]`` will only return a reference to an
1106 existing element at the given key. If the key is not found, it will throw
1107 ``libtorrent::type_error``.
1115 entry* find_key(char const* key);
1116 entry const* find_key(char const* key) const;
1118 These functions requires the entry to be a dictionary, if it isn't they
1119 will throw ``libtorrent::type_error``.
1121 They will look for an element at the given key in the dictionary, if the
1122 element cannot be found, they will return 0. If an element with the given
1123 key is found, the return a pointer to it.
1129 In previous versions of libtorrent, this class was also used for creating
1130 torrent files. This functionality has been moved to ``create_torrent``, see
1133 The ``torrent_info`` has the following synopsis::
1139 torrent_info(sha1_hash const& info_hash);
1140 torrent_info(lazy_entry const& torrent_file);
1141 torrent_info(char const* buffer, int size);
1142 torrent_info(boost::filesystem::path const& filename);
1144 void add_tracker(std::string const& url, int tier = 0);
1145 std::vector<announce_entry> const& trackers() const;
1147 file_storage const& files() const;
1149 typedef file_storage::iterator file_iterator;
1150 typedef file_storage::reverse_iterator reverse_file_iterator;
1152 file_iterator begin_files() const;
1153 file_iterator end_files() const;
1154 reverse_file_iterator rbegin_files() const;
1155 reverse_file_iterator rend_files() const;
1157 int num_files() const;
1158 file_entry const& file_at(int index) const;
1160 std::vector<file_slice> map_block(int piece, size_type offset
1162 peer_request map_file(int file_index, size_type file_offset
1167 std::vector<std::string> const& url_seeds() const;
1169 size_type total_size() const;
1170 int piece_length() const;
1171 int num_pieces() const;
1172 sha1_hash const& info_hash() const;
1173 std::string const& name() const;
1174 std::string const& comment() const;
1175 std::string const& creator() const;
1177 std::vector<std::pair<std::string, int> > const& nodes() const;
1178 void add_node(std::pair<std::string, int> const& node);
1180 boost::optional<boost::posix_time::ptime>
1181 creation_date() const;
1183 int piece_size(unsigned int index) const;
1184 sha1_hash const& hash_for_piece(unsigned int index) const;
1185 char const* hash_for_piece_ptr(unsigned int index) const;
1187 boost::shared_array<char> metadata() const;
1188 int metadata_size() const;
1196 torrent_info(sha1_hash const& info_hash);
1197 torrent_info(lazy_entry const& torrent_file);
1198 torrent_info(char const* buffer, int size);
1199 torrent_info(boost::filesystem::path const& filename);
1201 The constructor that takes an info-hash will initialize the info-hash to the given value,
1202 but leave all other fields empty. This is used internally when downloading torrents without
1203 the metadata. The metadata will be created by libtorrent as soon as it has been downloaded
1206 The constructor that takes a ``lazy_entry`` will create a ``torrent_info`` object from the
1207 information found in the given torrent_file. The ``lazy_entry`` represents a tree node in
1208 an bencoded file. To load an ordinary .torrent file
1209 into a ``lazy_entry``, use lazy_bdecode(), see `bdecode() bencode()`_.
1211 The version that takes a buffer pointer and a size will decode it as a .torrent file and
1212 initialize the torrent_info object for you.
1214 The version that takes a filename will simply load the torrent file and decode it inside
1215 the constructor, for convenience. This might not be the most suitable for applications that
1216 want to be able to report detailed errors on what might go wrong.
1224 void add_tracker(std::string const& url, int tier = 0);
1226 ``add_tracker()`` adds a tracker to the announce-list. The ``tier`` determines the order in
1227 which the trackers are to be tried. For more information see `trackers()`_.
1234 file_storage const& file() const;
1236 The ``file_storage`` object contains the information on how to map the pieces to
1237 files. It is separated from the ``torrent_info`` object because when creating torrents
1238 a storage object needs to be created without having a torrent file. When renaming files
1239 in a storage, the storage needs to make its own copy of the ``file_storage`` in order
1240 to make its mapping differ from the one in the torrent file.
1242 For more information on the ``file_storage`` object, see the separate document on how
1245 begin_files() end_files() rbegin_files() rend_files()
1246 -----------------------------------------------------
1250 file_iterator begin_files() const;
1251 file_iterator end_files() const;
1252 reverse_file_iterator rbegin_files() const;
1253 reverse_file_iterator rend_files() const;
1255 This class will need some explanation. First of all, to get a list of all files
1256 in the torrent, you can use ``begin_files()``, ``end_files()``,
1257 ``rbegin_files()`` and ``rend_files()``. These will give you standard vector
1258 iterators with the type ``file_entry``.
1264 boost::filesystem::path path;
1267 size_type file_base;
1268 boost::shared_ptr<const boost::filesystem::path> orig_path;
1271 The ``path`` is the full (relative) path of each file. i.e. if it is a multi-file
1272 torrent, all the files starts with a directory with the same name as ``torrent_info::name()``.
1273 The filenames are encoded with UTF-8.
1275 ``size`` is the size of the file (in bytes) and ``offset`` is the byte offset
1276 of the file within the torrent. i.e. the sum of all the sizes of the files
1277 before it in the list.
1279 ``file_base`` is the offset in the file where the storage should start. The normal
1280 case is to have this set to 0, so that the storage starts saving data at the start
1281 if the file. In cases where multiple files are mapped into the same file though,
1282 the ``file_base`` should be set to an offset so that the different regions do
1283 not overlap. This is used when mapping "unselected" files into a so-called part
1286 ``orig_path`` is set to 0 in case the path element is an exact copy of that
1287 found in the metadata. In case the path in the original metadata was
1288 incorrectly encoded, and had to be fixed in order to be acceptable utf-8,
1289 the original string is preserved in ``orig_path``. The reason to keep it
1290 is to be able to reproduce the info-section exactly, with the correct
1295 num_files() file_at()
1296 ---------------------
1300 int num_files() const;
1301 file_entry const& file_at(int index) const;
1303 If you need index-access to files you can use the ``num_files()`` and ``file_at()``
1304 to access files using indices.
1312 std::vector<file_slice> map_block(int piece, size_type offset
1315 This function will map a piece index, a byte offset within that piece and
1316 a size (in bytes) into the corresponding files with offsets where that data
1317 for that piece is supposed to be stored.
1319 The file slice struct looks like this::
1329 The ``file_index`` refers to the index of the file (in the torrent_info).
1330 To get the path and filename, use ``file_at()`` and give the ``file_index``
1331 as argument. The ``offset`` is the byte offset in the file where the range
1332 starts, and ``size`` is the number of bytes this range is. The size + offset
1333 will never be greater than the file size.
1341 peer_request map_file(int file_index, size_type file_offset
1344 This function will map a range in a specific file into a range in the torrent.
1345 The ``file_offset`` parameter is the offset in the file, given in bytes, where
1346 0 is the start of the file.
1347 The ``peer_request`` structure looks like this::
1354 bool operator==(peer_request const& r) const;
1357 ``piece`` is the index of the piece in which the range starts.
1358 ``start`` is the offset within that piece where the range starts.
1359 ``length`` is the size of the range, in bytes.
1361 The input range is assumed to be valid within the torrent. ``file_offset``
1362 + ``size`` is not allowed to be greater than the file size. ``file_index``
1363 must refer to a valid file, i.e. it cannot be >= ``num_files()``.
1366 url_seeds() add_url_seed()
1367 --------------------------
1371 std::vector<std::string> const& url_seeds() const;
1372 void add_url_seed(std::string const& url);
1374 If there are any url-seeds in this torrent, ``url_seeds()`` will return a
1375 vector of those urls. If you're creating a torrent file, ``add_url_seed()``
1376 adds one url to the list of url-seeds. Currently, the only transport protocol
1377 supported for the url is http.
1379 See `HTTP seeding`_ for more information.
1387 std::vector<announce_entry> const& trackers() const;
1389 The ``trackers()`` function will return a sorted vector of ``announce_entry``.
1390 Each announce entry contains a string, which is the tracker url, and a tier index. The
1391 tier index is the high-level priority. No matter which trackers that works or not, the
1392 ones with lower tier will always be tried before the one with higher tier number.
1396 struct announce_entry
1398 announce_entry(std::string const& url);
1404 total_size() piece_length() piece_size() num_pieces()
1405 -----------------------------------------------------
1409 size_type total_size() const;
1410 int piece_length() const;
1411 int piece_size(unsigned int index) const;
1412 int num_pieces() const;
1415 ``total_size()``, ``piece_length()`` and ``num_pieces()`` returns the total
1416 number of bytes the torrent-file represents (all the files in it), the number of byte for
1417 each piece and the total number of pieces, respectively. The difference between
1418 ``piece_size()`` and ``piece_length()`` is that ``piece_size()`` takes
1419 the piece index as argument and gives you the exact size of that piece. It will always
1420 be the same as ``piece_length()`` except in the case of the last piece, which may
1424 hash_for_piece() hash_for_piece_ptr() info_hash()
1425 -------------------------------------------------
1429 size_type piece_size(unsigned int index) const;
1430 sha1_hash const& hash_for_piece(unsigned int index) const;
1431 char const* hash_for_piece_ptr(unsigned int index) const;
1433 ``hash_for_piece()`` takes a piece-index and returns the 20-bytes sha1-hash for that
1434 piece and ``info_hash()`` returns the 20-bytes sha1-hash for the info-section of the
1435 torrent file. For more information on the ``sha1_hash``, see the big_number_ class.
1436 ``hash_for_piece_ptr()`` returns a pointer to the 20 byte sha1 digest for the piece.
1437 Note that the string is not null-terminated.
1440 name() comment() creation_date() creator()
1441 ------------------------------------------
1445 std::string const& name() const;
1446 std::string const& comment() const;
1447 boost::optional<boost::posix_time::ptime> creation_date() const;
1449 ``name()`` returns the name of the torrent.
1451 ``comment()`` returns the comment associated with the torrent. If there's no comment,
1452 it will return an empty string. ``creation_date()`` returns a `boost::posix_time::ptime`__
1453 object, representing the time when this torrent file was created. If there's no time stamp
1454 in the torrent file, this will return a date of January 1:st 1970.
1456 Both the name and the comment is UTF-8 encoded strings.
1458 ``creator()`` returns the creator string in the torrent. If there is no creator string
1459 it will return an empty string.
1461 __ http://www.boost.org/doc/html/date_time/posix_time.html#date_time.posix_time.ptime_class
1471 ``priv()`` returns true if this torrent is private. i.e., it should not be
1472 distributed on the trackerless network (the kademlia DHT).
1480 std::vector<std::pair<std::string, int> > const& nodes() const;
1482 If this torrent contains any DHT nodes, they are put in this vector in their original
1483 form (host name and port number).
1490 void add_node(std::pair<std::string, int> const& node);
1492 This is used when creating torrent. Use this to add a known DHT node. It may
1493 be used, by the client, to bootstrap into the DHT network.
1496 metadata() metadata_size()
1497 --------------------------
1501 boost::shared_array<char> metadata() const;
1502 int metadata_size() const;
1504 ``metadata()`` returns a the raw info section of the torrent file. The size
1505 of the metadata is returned by ``metadata_size()``.
1511 You will usually have to store your torrent handles somewhere, since it's the
1512 object through which you retrieve information about the torrent and aborts the torrent.
1513 Its declaration looks like this::
1515 struct torrent_handle
1519 torrent_status status();
1520 void file_progress(std::vector<size_type>& fp);
1521 void get_download_queue(std::vector<partial_piece_info>& queue) const;
1522 void get_peer_info(std::vector<peer_info>& v) const;
1523 torrent_info const& get_torrent_info() const;
1524 bool is_valid() const;
1526 std::string name() const;
1528 void save_resume_data() const;
1529 void force_reannounce() const;
1530 void force_reannounce(boost::posix_time::time_duration) const;
1531 void scrape_tracker() const;
1532 void connect_peer(asio::ip::tcp::endpoint const& adr, int source = 0) const;
1534 void set_tracker_login(std::string const& username
1535 , std::string const& password) const;
1537 std::vector<announce_entry> const& trackers() const;
1538 void replace_trackers(std::vector<announce_entry> const&);
1540 void add_url_seed(std::string const& url);
1541 void remove_url_seed(std::string const& url);
1542 std::set<std::string> url_seeds() const;
1544 void set_ratio(float ratio) const;
1545 void set_max_uploads(int max_uploads) const;
1546 void set_max_connections(int max_connections) const;
1547 void set_upload_limit(int limit) const;
1548 int upload_limit() const;
1549 void set_download_limit(int limit) const;
1550 int download_limit() const;
1551 void set_sequential_download(bool sd) const;
1552 bool is_sequential_download() const;
1554 void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
1555 void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
1557 int queue_position() const;
1558 void queue_position_up() const;
1559 void queue_position_down() const;
1560 void queue_position_top() const;
1561 void queue_position_bottom() const;
1563 void use_interface(char const* net_interface) const;
1566 void resume() const;
1567 bool is_paused() const;
1568 bool is_seed() const;
1569 void force_recheck() const;
1570 void clear_error() const;
1572 void resolve_countries(bool r);
1573 bool resolve_countries() const;
1575 void piece_priority(int index, int priority) const;
1576 int piece_priority(int index) const;
1578 void prioritize_pieces(std::vector<int> const& pieces) const;
1579 std::vector<int> piece_priorities() const;
1581 void prioritize_files(std::vector<int> const& files) const;
1583 bool is_auto_managed() const;
1584 void auto_managed(bool m) const;
1586 bool has_metadata() const;
1588 boost::filesystem::path save_path() const;
1589 void move_storage(boost::filesystem::path const& save_path) const;
1591 sha1_hash info_hash() const;
1593 bool operator==(torrent_handle const&) const;
1594 bool operator!=(torrent_handle const&) const;
1595 bool operator<(torrent_handle const&) const;
1598 The default constructor will initialize the handle to an invalid state. Which
1599 means you cannot perform any operation on it, unless you first assign it a
1600 valid handle. If you try to perform any operation on an uninitialized handle,
1601 it will throw ``invalid_handle``.
1603 .. warning:: All operations on a ``torrent_handle`` may throw invalid_handle_
1604 exception, in case the handle is no longer refering to a torrent. There is
1605 one exception ``is_valid()`` will never throw.
1606 Since the torrents are processed by a background thread, there is no
1607 guarantee that a handle will remain valid between two calls.
1610 piece_priority() prioritize_pieces() piece_priorities() prioritize_files()
1611 --------------------------------------------------------------------------
1615 void piece_priority(int index, int priority) const;
1616 int piece_priority(int index) const;
1617 void prioritize_pieces(std::vector<int> const& pieces) const;
1618 std::vector<int> piece_priorities() const;
1619 void prioritize_files(std::vector<int> const& files) const;
1621 These functions are used to set and get the prioritiy of individual pieces.
1622 By default all pieces have priority 1. That means that the random rarest
1623 first algorithm is effectively active for all pieces. You may however
1624 change the priority of individual pieces. There are 8 different priority
1627 0. piece is not downloaded at all
1628 1. normal priority. Download order is dependent on availability
1629 2. higher than normal priority. Pieces are preferred over pieces with
1630 the same availability, but not over pieces with lower availability
1631 3. pieces are as likely to be picked as partial pieces.
1632 4. pieces are preferred over partial pieces, but not over pieces with
1634 5. *currently the same as 4*
1635 6. piece is as likely to be picked as any piece with availability 1
1636 7. maximum priority, availability is disregarded, the piece is preferred
1637 over any other piece with lower priority
1639 The exact definitions of these priorities are implementation details, and
1640 subject to change. The interface guarantees that higher number means higher
1641 priority, and that 0 means do not download.
1643 ``piece_priority`` sets or gets the priority for an individual piece,
1644 specified by ``index``.
1646 ``prioritize_pieces`` takes a vector of integers, one integer per piece in
1647 the torrent. All the piece priorities will be updated with the priorities
1650 ``piece_priorities`` returns a vector with one element for each piece in the
1651 torrent. Each element is the current priority of that piece.
1653 ``prioritize_files`` takes a vector that has at as many elements as there are
1654 files in the torrent. Each entry is the priority of that file. The function
1655 sets the priorities of all the pieces in the torrent based on the vector.
1663 void file_progress(std::vector<size_type>& fp);
1665 This function fills in the supplied vector with the the number of bytes downloaded
1666 of each file in this torrent. The progress values are ordered the same as the files
1667 in the `torrent_info`_. This operation is not very cheap. Its complexity is *O(n + mj)*.
1668 Where *n* is the number of files, *m* is the number of downloading pieces and *j*
1669 is the number of blocks in a piece.
1677 boost::filesystem::path save_path() const;
1679 ``save_path()`` returns the path that was given to `add_torrent()`_ when this torrent
1687 void move_storage(boost::filesystem::path const& save_path) const;
1689 Moves the file(s) that this torrent are currently seeding from or downloading to. This
1690 operation will only have the desired effect if the given ``save_path`` is located on
1691 the same drive as the original save path. Since disk IO is performed in a separate
1692 thread, this operation is also asynchronous. Once the operation completes, the
1693 ``storage_moved_alert`` is generated, with the new path as the message.
1700 void force_reannounce() const;
1701 void force_reannounce(boost::posix_time::time_duration) const;
1703 ``force_reannounce()`` will force this torrent to do another tracker request, to receive new
1704 peers. The second overload of ``force_reannounce`` that takes a ``time_duration`` as
1705 argument will schedule a reannounce in that amount of time from now.
1712 void scrape_tracker() const;
1714 ``scrape_tracker()`` will send a scrape request to the tracker. A scrape request queries the
1715 tracker for statistics such as total number of incomplete peers, complete peers, number of
1718 This request will specifically update the ``num_complete`` and ``num_incomplete`` fields in
1719 the torrent_status_ struct once it completes. When it completes, it will generate a
1720 scrape_reply_alert_. If it fails, it will generate a scrape_failed_alert_.
1727 void connect_peer(asio::ip::tcp::endpoint const& adr, int source = 0) const;
1729 ``connect_peer()`` is a way to manually connect to peers that one believe is a part of the
1730 torrent. If the peer does not respond, or is not a member of this torrent, it will simply
1731 be disconnected. No harm can be done by using this other than an unnecessary connection
1732 attempt is made. If the torrent is uninitialized or in queued or checking mode, this
1733 will throw invalid_handle_. The second (optional) argument will be bitwised ORed into
1734 the source mask of this peer. Typically this is one of the source flags in peer_info_.
1735 i.e. ``tracker``, ``pex``, ``dht`` etc.
1743 std::string name() const;
1745 Returns the name of the torrent. i.e. the name from the metadata associated with it. In
1746 case the torrent was started without metadata, and hasn't completely received it yet,
1747 it returns the name given to it when added to the session. See ``session::add_torrent``.
1755 void set_ratio(float ratio) const;
1757 ``set_ratio()`` sets the desired download / upload ratio. If set to 0, it is considered being
1758 infinite. i.e. the client will always upload as much as it can, no matter how much it gets back
1759 in return. With this setting it will work much like the standard clients.
1761 Besides 0, the ratio can be set to any number greater than or equal to 1. It means how much to
1762 attempt to upload in return for each download. e.g. if set to 2, the client will try to upload
1763 2 bytes for every byte received. The default setting for this is 0, which will make it work
1764 as a standard client.
1767 set_upload_limit() set_download_limit() upload_limit() download_limit()
1768 -----------------------------------------------------------------------
1772 void set_upload_limit(int limit) const;
1773 void set_download_limit(int limit) const;
1774 int upload_limit() const;
1775 int download_limit() const;
1777 ``set_upload_limit`` will limit the upload bandwidth used by this particular torrent to the
1778 limit you set. It is given as the number of bytes per second the torrent is allowed to upload.
1779 ``set_download_limit`` works the same way but for download bandwidth instead of upload bandwidth.
1780 Note that setting a higher limit on a torrent then the global limit (``session::set_upload_rate_limit``)
1781 will not override the global rate limit. The torrent can never upload more than the global rate
1784 ``upload_limit`` and ``download_limit`` will return the current limit setting, for upload and
1785 download, respectively.
1788 set_sequential_download() is_sequential_download()
1789 --------------------------------------------------
1793 void set_sequential_download(bool sd);
1794 bool is_sequential_download() const;
1796 ``set_sequential_download()`` enables or disables *sequential download*. When enabled, the piece
1797 picker will pick pieces in sequence instead of rarest first.
1799 Enabling sequential download will affect the piece distribution negatively in the swarm. It should be
1802 ``is_sequential_download()`` returns true if this torrent is downloading in sequence, and false
1806 set_peer_upload_limit() set_peer_download_limit()
1807 -------------------------------------------------
1811 void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
1812 void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
1814 Works like ``set_upload_limit`` and ``set_download_limit`` respectively, but controls individual
1815 peer instead of the whole torrent.
1817 pause() resume() is_paused()
1818 ----------------------------
1823 void resume() const;
1824 bool is_paused() const;
1826 ``pause()``, and ``resume()`` will disconnect all peers and reconnect all peers respectively.
1827 When a torrent is paused, it will however remember all share ratios to all peers and remember
1828 all potential (not connected) peers. You can use ``is_paused()`` to determine if a torrent
1829 is currently paused. Torrents may be paused automatically if there is a file error (e.g. disk full)
1830 or something similar. See file_error_alert_.
1837 void force_recheck() const;
1839 ``force_recheck`` puts the torrent back in a state where it assumes to have no resume data.
1840 All peers will be disconnected and the torrent will stop announcing to the tracker. The torrent
1841 will be added to the checking queue, and will be checked (all the files will be read and
1842 compared to the piece hashes). Once the check is complete, the torrent will start connecting
1843 to peers again, as normal.
1850 void clear_error() const;
1852 If the torrent is in an error state (i.e. ``torrent_status::error`` is non-empty), this
1853 will clear the error and start the torrent again.
1860 void resolve_countries(bool r);
1861 bool resolve_countries() const;
1863 Sets or gets the flag that derermines if countries should be resolved for the peers of this
1864 torrent. It defaults to false. If it is set to true, the peer_info_ structure for the peers
1865 in this torrent will have their ``country`` member set. See peer_info_ for more information
1866 on how to interpret this field.
1873 bool is_seed() const;
1875 Returns true if the torrent is in seed mode (i.e. if it has finished downloading).
1877 is_auto_managed() auto_managed()
1878 --------------------------------
1882 bool is_auto_managed() const;
1883 void auto_managed(bool m) const;
1885 ``is_auto_managed()`` returns true if this torrent is currently *auto managed*.
1886 ``auto_managed()`` changes whether the torrent is auto managed or not. For more info,
1894 bool has_metadata() const;
1896 Returns true if this torrent has metadata (either it was started from a .torrent file or the
1897 metadata has been downloaded). The only scenario where this can return false is when the torrent
1898 was started torrent-less (i.e. with just an info-hash and tracker ip). Note that if the torrent
1899 doesn't have metadata, the member `get_torrent_info()`_ will throw.
1906 void set_tracker_login(std::string const& username
1907 , std::string const& password) const;
1909 ``set_tracker_login()`` sets a username and password that will be sent along in the HTTP-request
1910 of the tracker announce. Set this if the tracker requires authorization.
1913 trackers() replace_trackers()
1914 -----------------------------
1918 std::vector<announce_entry> const& trackers() const;
1919 void replace_trackers(std::vector<announce_entry> const&) const;
1921 ``trackers()`` will return the list of trackers for this torrent. The
1922 announce entry contains both a string ``url`` which specify the announce url
1923 for the tracker as well as an int ``tier``, which is specifies the order in
1924 which this tracker is tried. If you want libtorrent to use another list of
1925 trackers for this torrent, you can use ``replace_trackers()`` which takes
1926 a list of the same form as the one returned from ``trackers()`` and will
1927 replace it. If you want an immediate effect, you have to call
1928 `force_reannounce()`_.
1931 add_url_seed() remove_url_seed() url_seeds()
1932 --------------------------------------------
1936 void add_url_seed(std::string const& url);
1937 void remove_url_seed(std::string const& url);
1938 std::set<std::string> url_seeds() const;
1940 ``add_url_seed()`` adds another url to the torrent's list of url seeds. If the
1941 given url already exists in that list, the call has no effect. The torrent
1942 will connect to the server and try to download pieces from it, unless it's
1943 paused, queued, checking or seeding. ``remove_url_seed()`` removes the given
1944 url if it exists already. ``url_seeds()`` return a set of the url seeds
1945 currently in this torrent. Note that urls that fails may be removed
1946 automatically from the list.
1948 See `HTTP seeding`_ for more information.
1951 queue_position() queue_position_up() queue_position_down() queue_position_top() queue_position_bottom()
1952 -------------------------------------------------------------------------------------------------------
1956 int queue_position() const;
1957 void queue_position_up() const;
1958 void queue_position_down() const;
1959 void queue_position_top() const;
1960 void queue_position_bottom() const;
1962 Every torrent that is added is assigned a queue position exactly one greater than
1963 the greatest queue position of all existing torrents. Torrents that are being
1964 seeded have -1 as their queue position, since they're no longer in line to be downloaded.
1966 When a torrent is removed or turns into a seed, all torrents with greater queue positions
1967 have their positions decreased to fill in the space in the sequence.
1969 ``queue_position()`` returns the torrent's position in the download queue. The torrents
1970 with the smallest numbers are the ones that are being downloaded. The smaller number,
1971 the closer the torrent is to the front of the line to be started.
1973 The ``queue_position_*()`` functions adjust the torrents position in the queue. Up means
1974 closer to the front and down means closer to the back of the queue. Top and bottom refers
1975 to the front and the back of the queue respectively.
1983 void use_interface(char const* net_interface) const;
1985 ``use_interface()`` sets the network interface this torrent will use when it opens outgoing
1986 connections. By default, it uses the same interface as the session_ uses to listen on. The
1987 parameter must be a string containing an ip-address (either an IPv4 or IPv6 address). If
1988 the string does not conform to this format and exception is thrown.
1996 sha1_hash info_hash() const;
1998 ``info_hash()`` returns the info-hash for the torrent.
2001 set_max_uploads() set_max_connections()
2002 ---------------------------------------
2006 void set_max_uploads(int max_uploads) const;
2007 void set_max_connections(int max_connections) const;
2009 ``set_max_uploads()`` sets the maximum number of peers that's unchoked at the same time on this
2010 torrent. If you set this to -1, there will be no limit.
2012 ``set_max_connections()`` sets the maximum number of connection this torrent will open. If all
2013 connections are used up, incoming connections may be refused or poor connections may be closed.
2014 This must be at least 2. The default is unlimited number of connections. If -1 is given to the
2015 function, it means unlimited.
2023 void save_resume_data() const;
2025 ``save_resume_data()`` generates fast-resume data and returns it as an entry_. This entry_
2026 is suitable for being bencoded. For more information about how fast-resume works, see `fast resume`_.
2028 This operation is asynchronous, ``save_resume_data`` will return immediately. The resume data
2029 is delivered when it's done through an `save_resume_data_alert`_.
2031 The fast resume data will be empty in the following cases:
2033 1. The torrent handle is invalid.
2034 2. The torrent is checking (or is queued for checking) its storage, it will obviously
2035 not be ready to write resume data.
2036 3. The torrent hasn't received valid metadata and was started without metadata
2037 (see libtorrent's `metadata from peers`_ extension)
2039 Note that by the time you receive the fast resume data, it may already be invalid if the torrent
2040 is still downloading! The recommended practice is to first pause the torrent, then generate the
2041 fast resume data, and then close it down. Make sure to not `remove_torrent()`_ before you receive
2042 the `save_resume_data_alert`_ though. Only pause the torrent before you save the resume data
2043 if you will remove the torrent afterwards. There's no need to pause when saving intermittent
2046 In full allocation mode the reume data is never invalidated by subsequent
2047 writes to the files, since pieces won't move around. This means that you don't need to
2048 pause before writing resume data in full or sparse mode. If you don't, however, any data written to
2049 disk after you saved resume data and before the session_ closed is lost.
2051 It also means that if the resume data is out dated, libtorrent will not re-check the files, but assume
2052 that it is fairly recent. The assumption is that it's better to loose a little bit than to re-check
2055 It is still a good idea to save resume data periodically during download as well as when
2058 Example code to pause and save resume data for all torrents and wait for the alerts::
2060 int num_resume_data = 0;
2061 std::vector<torrent_handle> handles = ses.get_torrents();
2062 for (std::vector<torrent_handle>::iterator i = handles.begin();
2063 i != handles.end(); ++i)
2065 torrent_handle& h = *i;
2066 if (!h.has_metadata()) continue;
2069 h.save_resume_data();
2073 while (num_resume_data > 0)
2075 alert const* a = ses.wait_for_alert(seconds(10));
2077 // if we don't get an alert within 10 seconds, abort
2080 std::auto_ptr<alert> holder = ses.pop_alert();
2081 save_resume_data_alert const* rd = dynamic_cast<save_resume_data_alert const*>(a);
2088 torrent_handle h = rd->handle;
2089 boost::filesystem::ofstream out(h.save_path()
2090 / (h.get_torrent_info().name() + ".fastresume"), std::ios_base::binary);
2091 out.unsetf(std::ios_base::skipws);
2092 bencode(std::ostream_iterator<char>(out), *rd->resume_data);
2103 torrent_status status() const;
2105 ``status()`` will return a structure with information about the status of this
2106 torrent. If the torrent_handle_ is invalid, it will throw invalid_handle_ exception.
2107 See torrent_status_.
2110 get_download_queue()
2111 --------------------
2115 void get_download_queue(std::vector<partial_piece_info>& queue) const;
2117 ``get_download_queue()`` takes a non-const reference to a vector which it will fill with
2118 information about pieces that are partially downloaded or not downloaded at all but partially
2119 requested. The entry in the vector (``partial_piece_info``) looks like this::
2121 struct partial_piece_info
2124 int blocks_in_piece;
2125 block_info blocks[256];
2126 enum state_t { none, slow, medium, fast };
2127 state_t piece_state;
2130 ``piece_index`` is the index of the piece in question. ``blocks_in_piece`` is the
2131 number of blocks in this particular piece. This number will be the same for most pieces, but
2132 the last piece may have fewer blocks than the standard pieces.
2134 ``piece_state`` is set to either ``fast``, ``medium``, ``slow`` or ``none``. It tells which
2135 download rate category the peers downloading this piece falls into. ``none`` means that no
2136 peer is currently downloading any part of the piece. Peers prefer picking pieces from
2137 the same category as themselves. The reason for this is to keep the number of partially
2138 downloaded pieces down. Pieces set to ``none`` can be converted into any of ``fast``,
2139 ``medium`` or ``slow`` as soon as a peer want to download from it.
2146 { none, requested, writing, finished };
2150 unsigned num_peers:14;
2154 The ``block_info`` array contains data for each individual block in the piece. Each block has
2155 a state (``state``) which is any of:
2157 * ``none`` - This block has not been downloaded or requested form any peer.
2158 * ``requested`` - The block has been requested, but not completely downloaded yet.
2159 * ``writing`` - The block has been downloaded and is currently queued for being written to disk.
2160 * ``finished`` - The block has been written to disk.
2162 The ``peer`` field is the ip address of the peer this block was downloaded from.
2163 ``num_peers`` is the number of peers that is currently requesting this block. Typically this
2164 is 0 or 1, but at the end of the torrent blocks may be requested by more peers in parallel to
2172 void get_peer_info(std::vector<peer_info>&) const;
2174 ``get_peer_info()`` takes a reference to a vector that will be cleared and filled
2175 with one entry for each peer connected to this torrent, given the handle is valid. If the
2176 torrent_handle_ is invalid, it will throw invalid_handle_ exception. Each entry in
2177 the vector contains information about that particular peer. See peer_info_.
2185 torrent_info const& get_torrent_info() const;
2187 Returns a const reference to the torrent_info_ object associated with this torrent.
2188 This reference is valid as long as the torrent_handle_ is valid, no longer. If the
2189 torrent_handle_ is invalid or if it doesn't have any metadata, invalid_handle_
2190 exception will be thrown. The torrent may be in a state without metadata only if
2191 it was started without a .torrent file, i.e. by using the libtorrent extension of
2192 just supplying a tracker and info-hash.
2200 bool is_valid() const;
2202 Returns true if this handle refers to a valid torrent and false if it hasn't been initialized
2203 or if the torrent it refers to has been aborted. Note that a handle may become invalid after
2204 it has been added to the session. Usually this is because the storage for the torrent is
2205 somehow invalid or if the filenames are not allowed (and hence cannot be opened/created) on
2206 your filesystem. If such an error occurs, a file_error_alert_ is generated and all handles
2207 that refers to that torrent will become invalid.
2213 It contains the following fields::
2215 struct torrent_status
2219 queued_for_checking,
2221 connecting_to_tracker,
2222 downloading_metadata,
2234 boost::posix_time::time_duration next_announce;
2235 boost::posix_time::time_duration announce_interval;
2237 std::string current_tracker;
2239 size_type total_download;
2240 size_type total_upload;
2242 size_type total_payload_download;
2243 size_type total_payload_upload;
2245 size_type total_failed_bytes;
2246 size_type total_redundant_bytes;
2248 float download_rate;
2251 float download_payload_rate;
2252 float upload_payload_rate;
2262 int connect_candidates;
2267 size_type total_done;
2268 size_type total_wanted_done;
2269 size_type total_wanted;
2272 float distributed_copies;
2277 int num_connections;
2279 int connections_limit;
2281 storage_mode_t storage_mode;
2283 int up_bandwidth_queue;
2284 int down_bandwidth_queue;
2286 size_type all_time_upload;
2287 size_type all_time_download;
2299 ``progress`` is a value in the range [0, 1], that represents the progress of the
2300 torrent's current task. It may be checking files or downloading. The torrent's
2301 current task is in the ``state`` member, it will be one of the following:
2303 +--------------------------+----------------------------------------------------------+
2304 |``queued_for_checking`` |The torrent is in the queue for being checked. But there |
2305 | |currently is another torrent that are being checked. |
2306 | |This torrent will wait for its turn. |
2307 +--------------------------+----------------------------------------------------------+
2308 |``checking_files`` |The torrent has not started its download yet, and is |
2309 | |currently checking existing files. |
2310 +--------------------------+----------------------------------------------------------+
2311 |``connecting_to_tracker`` |The torrent has sent a request to the tracker and is |
2312 | |currently waiting for a response |
2313 +--------------------------+----------------------------------------------------------+
2314 |``downloading_metadata`` |The torrent is trying to download metadata from peers. |
2315 | |This assumes the metadata_transfer extension is in use. |
2316 +--------------------------+----------------------------------------------------------+
2317 |``downloading`` |The torrent is being downloaded. This is the state |
2318 | |most torrents will be in most of the time. The progress |
2319 | |meter will tell how much of the files that has been |
2321 +--------------------------+----------------------------------------------------------+
2322 |``finished`` |In this state the torrent has finished downloading but |
2323 | |still doesn't have the entire torrent. i.e. some pieces |
2324 | |are filtered and won't get downloaded. |
2325 +--------------------------+----------------------------------------------------------+
2326 |``seeding`` |In this state the torrent has finished downloading and |
2327 | |is a pure seeder. |
2328 +--------------------------+----------------------------------------------------------+
2329 |``allocating`` |If the torrent was started in full allocation mode, this |
2330 | |indicates that the (disk) storage for the torrent is |
2332 +--------------------------+----------------------------------------------------------+
2335 When downloading, the progress is ``total_wanted_done`` / ``total_wanted``.
2337 ``paused`` is set to true if the torrent is paused and false otherwise.
2339 ``error`` may be set to an error message describing why the torrent was paused, in
2340 case it was paused by an error. If the torrent is not paused or if it's paused but
2341 not because of an error, this string is empty.
2343 ``next_announce`` is the time until the torrent will announce itself to the tracker. And
2344 ``announce_interval`` is the time the tracker want us to wait until we announce ourself
2345 again the next time.
2347 ``current_tracker`` is the URL of the last working tracker. If no tracker request has
2348 been successful yet, it's set to an empty string.
2350 ``total_download`` and ``total_upload`` is the number of bytes downloaded and
2351 uploaded to all peers, accumulated, *this session* only.
2353 ``total_payload_download`` and ``total_payload_upload`` counts the amount of bytes
2354 send and received this session, but only the actual payload data (i.e the interesting
2355 data), these counters ignore any protocol overhead.
2357 ``total_failed_bytes`` is the number of bytes that has been downloaded and that
2358 has failed the piece hash test. In other words, this is just how much crap that
2359 has been downloaded.
2361 ``total_redundant_bytes`` is the number of bytes that has been downloaded even
2362 though that data already was downloaded. The reason for this is that in some
2363 situations the same data can be downloaded by mistake. When libtorrent sends
2364 requests to a peer, and the peer doesn't send a response within a certain
2365 timeout, libtorrent will re-request that block. Another situation when
2366 libtorrent may re-request blocks is when the requests it sends out are not
2367 replied in FIFO-order (it will re-request blocks that are skipped by an out of
2368 order block). This is supposed to be as low as possible.
2370 ``pieces`` is the bitmask that represents which pieces we have (set to true) and
2371 the pieces we don't have. It's a pointer and may be set to 0 if the torrent isn't
2372 downloading or seeding.
2374 ``num_pieces`` is the number of pieces that has been downloaded. It is equivalent
2375 to: ``std::accumulate(pieces->begin(), pieces->end())``. So you don't have to
2376 count yourself. This can be used to see if anything has updated since last time
2377 if you want to keep a graph of the pieces up to date.
2379 ``download_rate`` and ``upload_rate`` are the total rates for all peers for this
2380 torrent. These will usually have better precision than summing the rates from
2381 all peers. The rates are given as the number of bytes per second. The
2382 ``download_payload_rate`` and ``upload_payload_rate`` respectively is the
2383 total transfer rate of payload only, not counting protocol chatter. This might
2384 be slightly smaller than the other rates, but if projected over a long time
2385 (e.g. when calculating ETA:s) the difference may be noticeable.
2387 ``num_peers`` is the number of peers this torrent currently is connected to.
2388 Peer connections that are in the half-open state (is attempting to connect)
2389 or are queued for later connection attempt do not count. Although they are
2390 visible in the peer list when you call `get_peer_info()`_.
2392 ``num_complete`` and ``num_incomplete`` are set to -1 if the tracker did not
2393 send any scrape data in its announce reply. This data is optional and may
2394 not be available from all trackers. If these are not -1, they are the total
2395 number of peers that are seeding (complete) and the total number of peers
2396 that are still downloading (incomplete) this torrent.
2398 ``list_seeds`` and ``list_peers`` are the number of seeds in our peer list
2399 and the total number of peers (including seeds) respectively. We are not
2400 necessarily connected to all the peers in our peer list. This is the number
2401 of peers we know of in total, including banned peers and peers that we have
2402 failed to connect to.
2404 ``connect_candidates`` is the number of peers in this torrent's peer list
2405 that is a candidate to be connected to. i.e. It has fewer connect attempts
2406 than the max fail count, it is not a seed if we are a seed, it is not banned
2407 etc. If this is 0, it means we don't know of any more peers that we can try.
2409 ``total_done`` is the total number of bytes of the file(s) that we have. All
2410 this does not necessarily has to be downloaded during this session (that's
2411 ``total_payload_download``).
2413 ``total_wanted_done`` is the number of bytes we have downloaded, only counting the
2414 pieces that we actually want to download. i.e. excluding any pieces that we have but
2415 are filtered as not wanted.
2417 ``total_wanted`` is the total number of bytes we want to download. This is also
2418 excluding pieces that have been filtered.
2420 ``num_seeds`` is the number of peers that are seeding that this client is
2421 currently connected to.
2423 ``distributed_copies`` is the number of distributed copies of the torrent.
2424 Note that one copy may be spread out among many peers. The integer part
2425 tells how many copies there are currently of the rarest piece(s) among the
2426 peers this client is connected to. The fractional part tells the share of
2427 pieces that have more copies than the rarest piece(s). For example: 2.5 would
2428 mean that the rarest pieces have only 2 copies among the peers this torrent is
2429 connected to, and that 50% of all the pieces have more than two copies.
2431 If we are a seed, the piece picker is deallocated as an optimization, and
2432 piece availability is no longer tracked. In this case the distributed
2433 copies is set to -1.
2435 ``block_size`` is the size of a block, in bytes. A block is a sub piece, it
2436 is the number of bytes that each piece request asks for and the number of
2437 bytes that each bit in the ``partial_piece_info``'s bitset represents
2438 (see `get_download_queue()`_). This is typically 16 kB, but it may be
2439 larger if the pieces are larger.
2441 ``num_uploads`` is the number of unchoked peers in this torrent.
2443 ``num_connections`` is the number of peer connections this torrent has, including
2444 half-open connections that hasn't completed the bittorrent handshake yet. This is
2445 always <= ``num_peers``.
2447 ``uploads_limit`` is the set limit of upload slots (unchoked peers) for this torrent.
2449 ``connections_limit`` is the set limit of number of connections for this torrent.
2451 ``storage_mode`` is one of ``storage_mode_allocate``, ``storage_mode_sparse`` or
2452 ``storage_mode_compact``. Identifies which storage mode this torrent is being saved
2453 with. See `Storage allocation`_.
2455 ``up_bandwidth_queue`` and ``down_bandwidth_queue`` are the number of peers in this
2456 torrent that are waiting for more bandwidth quota from the torrent rate limiter.
2457 This can determine if the rate you get from this torrent is bound by the torrents
2458 limit or not. If there is no limit set on this torrent, the peers might still be
2459 waiting for bandwidth quota from the global limiter, but then they are counted in
2460 the ``session_status`` object.
2462 ``all_time_upload`` and ``all_time_download`` are accumulated upload and download
2463 byte counters. They are saved in and restored from resume data to keep totals
2466 ``active_time`` and ``seeding_time`` are second counters. They keep track of the
2467 number of seconds this torrent has been active (not paused) and the number of
2468 seconds it has been active while being a seed. ``seeding_time`` should be >=
2469 ``active_time`` They are saved in and restored from resume data, to keep totals
2472 ``seed_rank`` is a rank of how important it is to seed the torrent, it is used
2473 to determine which torrents to seed and which to queue. It is based on the peer
2474 to seed ratio from the tracker scrape. For more information, see queuing_.
2476 ``last_scrape`` is the number of seconds since this torrent acquired scrape data.
2477 If it has never done that, this value is -1.
2479 ``has_incoming`` is true if there has ever been an incoming connection attempt
2486 It contains the following fields::
2494 remote_interested = 0x4,
2495 remote_choked = 0x8,
2496 supports_extensions = 0x10,
2497 local_connection = 0x20,
2503 optimistic_unchoke = 0x800,
2505 upload_only = 0x2000,
2506 rc4_encrypted = 0x100000,
2507 plaintext_encrypted = 0x200000
2512 enum peer_source_flags
2522 enum bw_state { bw_idle, bw_torrent, bw_global, bw_network };
2527 asio::ip::tcp::endpoint ip;
2530 float payload_up_speed;
2531 float payload_down_speed;
2532 size_type total_download;
2533 size_type total_upload;
2539 time_duration last_request;
2540 time_duration last_active;
2541 int request_timeout;
2543 int send_buffer_size;
2544 int used_send_buffer;
2546 int receive_buffer_size;
2547 int used_receive_buffer;
2553 std::string inet_as_name;
2556 size_type load_balancing;
2558 int requests_in_buffer;
2559 int download_queue_length;
2560 int upload_queue_length;
2564 int downloading_piece_index;
2565 int downloading_block_index;
2566 int downloading_progress;
2567 int downloading_total;
2573 standard_bittorrent = 0,
2576 int connection_type;
2580 int pending_disk_bytes;
2587 int download_rate_peak;
2588 int upload_rate_peak;
2592 The ``flags`` attribute tells you in which state the peer is. It is set to
2593 any combination of the enums above. The following table describes each flag:
2595 +-------------------------+-------------------------------------------------------+
2596 | ``interesting`` | **we** are interested in pieces from this peer. |
2597 +-------------------------+-------------------------------------------------------+
2598 | ``choked`` | **we** have choked this peer. |
2599 +-------------------------+-------------------------------------------------------+
2600 | ``remote_interested`` | the peer is interested in **us** |
2601 +-------------------------+-------------------------------------------------------+
2602 | ``remote_choked`` | the peer has choked **us**. |
2603 +-------------------------+-------------------------------------------------------+
2604 | ``support_extensions`` | means that this peer supports the |
2605 | | `extension protocol`__. |
2606 +-------------------------+-------------------------------------------------------+
2607 | ``local_connection`` | The connection was initiated by us, the peer has a |
2608 | | listen port open, and that port is the same as in the |
2609 | | address of this peer. If this flag is not set, this |
2610 | | peer connection was opened by this peer connecting to |
2612 +-------------------------+-------------------------------------------------------+
2613 | ``handshake`` | The connection is opened, and waiting for the |
2614 | | handshake. Until the handshake is done, the peer |
2615 | | cannot be identified. |
2616 +-------------------------+-------------------------------------------------------+
2617 | ``connecting`` | The connection is in a half-open state (i.e. it is |
2618 | | being connected). |
2619 +-------------------------+-------------------------------------------------------+
2620 | ``queued`` | The connection is currently queued for a connection |
2621 | | attempt. This may happen if there is a limit set on |
2622 | | the number of half-open TCP connections. |
2623 +-------------------------+-------------------------------------------------------+
2624 | ``on_parole`` | The peer has participated in a piece that failed the |
2625 | | hash check, and is now "on parole", which means we're |
2626 | | only requesting whole pieces from this peer until |
2627 | | it either fails that piece or proves that it doesn't |
2628 | | send bad data. |
2629 +-------------------------+-------------------------------------------------------+
2630 | ``seed`` | This peer is a seed (it has all the pieces). |
2631 +-------------------------+-------------------------------------------------------+
2632 | ``optimistic_unchoke`` | This peer is subject to an optimistic unchoke. It has |
2633 | | been unchoked for a while to see if it might unchoke |
2634 | | us in return an earn an upload/unchoke slot. If it |
2635 | | doesn't within some period of time, it will be choked |
2636 | | and another peer will be optimistically unchoked. |
2637 +-------------------------+-------------------------------------------------------+
2638 | ``snubbed`` | This peer has recently failed to send a block within |
2639 | | the request timeout from when the request was sent. |
2640 | | We're currently picking one block at a time from this |
2642 +-------------------------+-------------------------------------------------------+
2643 | ``upload_only`` | This peer has either explicitly (with an extension) |
2644 | | or implicitly (by becoming a seed) told us that it |
2645 | | will not downloading anything more, regardless of |
2646 | | which pieces we have. |
2647 +-------------------------+-------------------------------------------------------+
2649 __ extension_protocol.html
2651 ``source`` is a combination of flags describing from which sources this peer
2652 was received. The flags are:
2654 +------------------------+--------------------------------------------------------+
2655 | ``tracker`` | The peer was received from the tracker. |
2656 +------------------------+--------------------------------------------------------+
2657 | ``dht`` | The peer was received from the kademlia DHT. |
2658 +------------------------+--------------------------------------------------------+
2659 | ``pex`` | The peer was received from the peer exchange |
2661 +------------------------+--------------------------------------------------------+
2662 | ``lsd`` | The peer was received from the local service |
2663 | | discovery (The peer is on the local network). |
2664 +------------------------+--------------------------------------------------------+
2665 | ``resume_data`` | The peer was added from the fast resume data. |
2666 +------------------------+--------------------------------------------------------+
2668 ``read_state`` and ``write_state`` indicates what state this peer is in with regards
2669 to sending and receiving data. The states are declared in the ``bw_state`` enum and
2672 +------------------------+--------------------------------------------------------+
2673 | ``bw_idle`` | The peer is not waiting for any external events to |
2674 | | send or receive data. |
2676 +------------------------+--------------------------------------------------------+
2677 | ``bw_torrent`` | The peer is waiting for the torrent to receive |
2678 | | bandwidth quota in order to forward the bandwidth |
2679 | | request to the global manager. |
2681 +------------------------+--------------------------------------------------------+
2682 | ``bw_global`` | The peer is waiting for the global bandwidth manager |
2683 | | to receive more quota in order to handle the request. |
2685 +------------------------+--------------------------------------------------------+
2686 | ``bw_network`` | The peer has quota and is currently waiting for a |
2687 | | network read or write operation to complete. This is |
2688 | | the state all peers are in if there are no bandwidth |
2691 +------------------------+--------------------------------------------------------+
2693 The ``ip`` field is the IP-address to this peer. The type is an asio endpoint. For
2694 more info, see the asio_ documentation.
2696 .. _asio: http://asio.sf.net
2698 ``up_speed`` and ``down_speed`` contains the current upload and download speed
2699 we have to and from this peer (including any protocol messages). The transfer rates
2700 of payload data only are found in ``payload_up_speed`` and ``payload_down_speed``.
2701 These figures are updated approximately once every second.
2703 ``total_download`` and ``total_upload`` are the total number of bytes downloaded
2704 from and uploaded to this peer. These numbers do not include the protocol chatter, but only
2707 ``pid`` is the peer's id as used in the bit torrent protocol. This id can be used to
2708 extract 'fingerprints' from the peer. Sometimes it can tell you which client the peer
2709 is using. See identify_client()_
2711 ``pieces`` is a bitfield, with one bit per piece in the torrent.
2712 Each bit tells you if the peer has that piece (if it's set to 1)
2713 or if the peer miss that piece (set to 0).
2715 ``seed`` is true if this peer is a seed.
2717 ``upload_limit`` is the number of bytes per second we are allowed to send to this
2718 peer every second. It may be -1 if there's no local limit on the peer. The global
2719 limit and the torrent limit is always enforced anyway.
2721 ``download_limit`` is the number of bytes per second this peer is allowed to
2722 receive. -1 means it's unlimited.
2724 ``last_request`` and ``last_active`` is the time since we last sent a request
2725 to this peer and since any transfer occurred with this peer, respectively.
2727 ``request_timeout`` is the number of seconds until the current front piece request
2728 will time out. This timeout can be adjusted through ``session_settings::request_timeout``.
2729 -1 means that there is not outstanding request.
2731 ``send_buffer_size`` and ``used_send_buffer`` is the number of bytes allocated
2732 and used for the peer's send buffer, respectively.
2734 ``receive_buffer_size`` and ``used_receive_buffer`` are the number of bytes
2735 allocated and used as receive buffer, respectively.
2737 ``num_hashfails`` is the number of pieces this peer has participated in
2738 sending us that turned out to fail the hash check.
2740 ``country`` is the two letter `ISO 3166 country code`__ for the country the peer
2741 is connected from. If the country hasn't been resolved yet, both chars are set
2742 to 0. If the resolution failed for some reason, the field is set to "--". If the
2743 resolution service returns an invalid country code, it is set to "!!".
2744 The ``countries.nerd.dk`` service is used to look up countries. This field will
2745 remain set to 0 unless the torrent is set to resolve countries, see `resolve_countries()`_.
2747 __ http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
2749 ``inet_as_name`` is the name of the AS this peer is located in. This might be
2750 an empty string if there is no name in the geo ip database.
2752 ``inet_as`` is the AS number the peer is located in.
2754 ``load_balancing`` is a measurement of the balancing of free download (that we get)
2755 and free upload that we give. Every peer gets a certain amount of free upload, but
2756 this member says how much *extra* free upload this peer has got. If it is a negative
2757 number it means that this was a peer from which we have got this amount of free
2760 ``requests_in_buffer`` is the number of requests messages that are currently in the
2761 send buffer waiting to be sent.
2763 ``download_queue_length`` is the number of piece-requests we have sent to this peer
2764 that hasn't been answered with a piece yet.
2766 ``upload_queue_length`` is the number of piece-requests we have received from this peer
2767 that we haven't answered with a piece yet.
2769 ``failcount`` is the number of times this peer has "failed". i.e. failed to connect
2770 or disconnected us. The failcount is decremented when we see this peer in a tracker
2771 response or peer exchange message.
2773 You can know which piece, and which part of that piece, that is currently being
2774 downloaded from a specific peer by looking at the next four members.
2775 ``downloading_piece_index`` is the index of the piece that is currently being downloaded.
2776 This may be set to -1 if there's currently no piece downloading from this peer. If it is
2777 >= 0, the other three members are valid. ``downloading_block_index`` is the index of the
2778 block (or sub-piece) that is being downloaded. ``downloading_progress`` is the number
2779 of bytes of this block we have received from the peer, and ``downloading_total`` is
2780 the total number of bytes in this block.
2782 ``client`` is a string describing the software at the other end of the connection.
2783 In some cases this information is not available, then it will contain a string
2784 that may give away something about which software is running in the other end.
2785 In the case of a web seed, the server type and version will be a part of this
2788 ``connection_type`` can currently be one of ``standard_bittorrent`` or
2789 ``web_seed``. These are currently the only implemented protocols.
2791 ``remote_dl_rate`` is an estimate of the rate this peer is downloading at, in
2794 ``pending_disk_bytes`` is the number of bytes this peer has pending in the
2795 disk-io thread. Downloaded and waiting to be written to disk. This is what
2796 is capped by ``session_settings::max_outstanding_disk_bytes_per_connection``.
2798 ``send_quota`` and ``receive_quota`` are the number of bytes this peer has been
2799 assigned to be allowed to send and receive until it has to request more quota
2800 from the bandwidth manager.
2802 ``rtt`` is an estimated round trip time to this peer, in milliseconds. It is
2803 estimated by timing the the tcp ``connect()``. It may be 0 for incoming connections.
2805 ``download_rate_peak`` and ``upload_rate_peak`` are the highest download and upload
2806 rates seen on this connection. They are given in bytes per second. This number is
2807 reset to 0 on reconnect.
2812 You have some control over tracker requests through the ``session_settings`` object. You
2813 create it and fill it with your settings and then use ``session::set_settings()``
2814 to apply them. You have control over proxy and authorization settings and also the user-agent
2815 that will be sent to the tracker. The user-agent is a good way to identify your client.
2819 struct session_settings
2822 std::string user_agent;
2823 int tracker_completion_timeout;
2824 int tracker_receive_timeout;
2825 int stop_tracker_timeout;
2826 int tracker_maximum_response_length;
2829 float request_queue_time;
2830 int max_allowed_in_request_queue;
2831 int max_out_request_queue;
2832 int whole_pieces_threshold;
2834 int urlseed_timeout;
2835 int urlseed_pipeline_size;
2837 bool allow_multiple_connections_per_ip;
2839 int min_reconnect_time;
2840 int peer_connect_timeout;
2841 bool ignore_limits_on_local_network;
2842 int connection_speed;
2843 bool send_redundant_have;
2844 bool lazy_bitfields;
2845 int inactivity_timeout;
2846 int unchoke_interval;
2847 int optimistic_unchoke_multiplier;
2848 address announce_ip;
2850 int initial_picker_threshold;
2851 int allowed_fast_set_size;
2852 int max_outstanding_disk_bytes_per_connection;
2853 int handshake_timeout;
2854 bool use_dht_as_fallback;
2855 bool free_torrent_hashes;
2856 bool upnp_ignore_nonrouters;
2857 int send_buffer_watermark;
2858 bool auto_upload_slots;
2859 bool use_parole_mode;
2862 std::pair<int, int> outgoing_ports;
2865 int active_downloads;
2868 bool dont_count_slow_torrents;
2869 int auto_manage_interval;
2870 float share_ratio_limit;
2871 float seed_time_ratio_limit;
2872 int seed_time_limit;
2873 bool close_redundant_connections;
2875 int auto_scrape_interval;
2876 int auto_scrape_min_interval;
2878 int max_peerlist_size;
2881 ``user_agent`` this is the client identification to the tracker.
2882 The recommended format of this string is:
2883 "ClientName/ClientVersion libtorrent/libtorrentVersion".
2884 This name will not only be used when making HTTP requests, but also when
2885 sending extended headers to peers that support that extension.
2887 ``tracker_completion_timeout`` is the number of seconds the tracker
2888 connection will wait from when it sent the request until it considers the
2889 tracker to have timed-out. Default value is 60 seconds.
2891 ``tracker_receive_timeout`` is the number of seconds to wait to receive
2892 any data from the tracker. If no data is received for this number of
2893 seconds, the tracker will be considered as having timed out. If a tracker
2894 is down, this is the kind of timeout that will occur. The default value
2897 ``stop_tracker_timeout`` is the time to wait for tracker responses when
2898 shutting down the session object. This is given in seconds. Default is
2901 ``tracker_maximum_response_length`` is the maximum number of bytes in a
2902 tracker response. If a response size passes this number it will be rejected
2903 and the connection will be closed. On gzipped responses this size is measured
2904 on the uncompressed data. So, if you get 20 bytes of gzip response that'll
2905 expand to 2 megs, it will be interrupted before the entire response has been
2906 uncompressed (given your limit is lower than 2 megs). Default limit is
2909 ``piece_timeout`` controls the number of seconds from a request is sent until
2910 it times out if no piece response is returned.
2912 ``request_queue_time`` is the length of the request queue given in the number
2913 of seconds it should take for the other end to send all the pieces. i.e. the
2914 actual number of requests depends on the download rate and this number.
2916 ``max_allowed_in_request_queue`` is the number of outstanding block requests
2917 a peer is allowed to queue up in the client. If a peer sends more requests
2918 than this (before the first one has been handled) the last request will be
2919 dropped. The higher this is, the faster upload speeds the client can get to a
2922 ``max_out_request_queue`` is the maximum number of outstanding requests to
2923 send to a peer. This limit takes precedence over ``request_queue_time``. i.e.
2924 no matter the download speed, the number of outstanding requests will never
2927 ``whole_pieces_threshold`` is a limit in seconds. if a whole piece can be
2928 downloaded in at least this number of seconds from a specific peer, the
2929 peer_connection will prefer requesting whole pieces at a time from this peer.
2930 The benefit of this is to better utilize disk caches by doing localized
2931 accesses and also to make it easier to identify bad peers if a piece fails
2934 ``peer_timeout`` is the number of seconds the peer connection should
2935 wait (for any activity on the peer connection) before closing it due
2936 to time out. This defaults to 120 seconds, since that's what's specified
2937 in the protocol specification. After half the time out, a keep alive message
2940 ``urlseed_timeout`` is the same as ``peer_timeout`` but applies only to
2941 url seeds. This value defaults to 20 seconds.
2943 ``urlseed_pipeline_size`` controls the pipelining with the web server. When
2944 using persistent connections to HTTP 1.1 servers, the client is allowed to
2945 send more requests before the first response is received. This number controls
2946 the number of outstanding requests to use with url-seeds. Default is 5.
2948 ``file_pool_size`` is the the upper limit on the total number of files this
2949 session will keep open. The reason why files are left open at all is that
2950 some anti virus software hooks on every file close, and scans the file for
2951 viruses. deferring the closing of the files will be the difference between
2952 a usable system and a completely hogged down system. Most operating systems
2953 also has a limit on the total number of file descriptors a process may have
2954 open. It is usually a good idea to find this limit and set the number of
2955 connections and the number of files limits so their sum is slightly below it.
2957 ``allow_multiple_connections_per_ip`` determines if connections from the
2958 same IP address as existing connections should be rejected or not. Multiple
2959 connections from the same IP address is not allowed by default, to prevent
2960 abusive behavior by peers. It may be useful to allow such connections in
2961 cases where simulations are run on the same machie, and all peers in a
2962 swarm has the same IP address.
2964 ``max_failcount`` is the maximum times we try to connect to a peer before
2965 stop connecting again. If a peer succeeds, the failcounter is reset. If
2966 a peer is retrieved from a peer source (other than DHT) the failcount is
2967 decremented by one, allowing another try.
2969 ``min_reconnect_time`` is the time to wait between connection attempts. If
2970 the peer fails, the time is multiplied by fail counter.
2972 ``peer_connect_timeout`` the number of seconds to wait after a connection
2973 attempt is initiated to a peer until it is considered as having timed out.
2974 The default is 10 seconds. This setting is especially important in case
2975 the number of half-open connections are limited, since stale half-open
2976 connection may delay the connection of other peers considerably.
2978 ``ignore_limits_on_local_network``, if set to true, upload, download and
2979 unchoke limits are ignored for peers on the local network.
2981 ``connection_speed`` is the number of connection attempts that
2982 are made per second. If a number <= 0 is specified, it will default to
2983 200 connections per second.
2985 ``send_redundant_have`` controls if have messages will be sent
2986 to peers that already have the piece. This is typically not necessary,
2987 but it might be necessary for collecting statistics in some cases.
2990 ``lazy_bitfields`` prevents outgoing bitfields from being full. If the
2991 client is seed, a few bits will be set to 0, and later filled in with
2992 have-messages. This is to prevent certain ISPs from stopping people
2995 ``inactivity_timeout``, if a peer is uninteresting and uninterested
2996 for longer than this number of seconds, it will be disconnected.
2997 Default is 10 minutes
2999 ``unchoke_interval`` is the number of seconds between chokes/unchokes.
3000 On this interval, peers are re-evaluated for being choked/unchoked. This
3001 is defined as 30 seconds in the protocol, and it should be significantly
3002 longer than what it takes for TCP to ramp up to it's max rate.
3004 ``optimistic_unchoke_multiplier`` is the number of unchoke intervals between
3005 each *optimistic* unchoke interval. On this timer, the currently optimistically
3006 unchoked peer will change.
3008 ``announce_ip`` is the ip address passed along to trackers as the ``&ip=`` parameter.
3009 If left as the default (default constructed), that parameter is ommited.
3011 ``num_want`` is the number of peers we want from each tracker request. It defines
3012 what is sent as the ``&num_want=`` parameter to the tracker.
3014 ``initial_picker_threshold`` specifies the number of pieces we need before we
3015 switch to rarest first picking. This defaults to 4, which means the 4 first
3016 pieces in any torrent are picked at random, the following pieces are picked
3017 in rarest first order.
3019 ``allowed_fast_set_size`` is the number of pieces we allow peers to download
3020 from us without being unchoked.
3022 ``max_outstanding_disk_bytes_per_connection`` is the number of bytes each
3023 connection is allowed to have waiting in the disk I/O queue before it is
3024 throttled back. This limit is meant to stop fast internet connections to
3025 queue up bufferes indefinitely on slow hard-drives or storage.
3027 ``handshake_timeout`` specifies the number of seconds we allow a peer to
3028 delay responding to a protocol handshake. If no response is received within
3029 this time, the connection is closed.
3031 ``use_dht_as_fallback`` determines how the DHT is used. If this is true
3032 (which it is by default), the DHT will only be used for torrents where
3033 all trackers in its tracker list has failed. Either by an explicit error
3034 message or a time out.
3036 ``free_torrent_hashes`` determines whether or not the torrent's piece hashes
3037 are kept in memory after the torrent becomes a seed or not. If it is set to
3038 ``true`` the hashes are freed once the torrent is a seed (they're not
3039 needed anymore since the torrent won't download anything more). If it's set
3040 to false they are not freed. If they are freed, the torrent_info_ returned
3041 by get_torrent_info() will return an object that may be incomplete, that
3042 cannot be passed back to `add_torrent()`_ for instance.
3044 ``upnp_ignore_nonrouters`` indicates whether or not the UPnP implementation
3045 should ignore any broadcast response from a device whose address is not the
3046 configured router for this machine. i.e. it's a way to not talk to other
3047 people's routers by mistake.
3049 ``send_buffer_waterbark`` is the upper limit of the send buffer low-watermark.
3050 if the send buffer has fewer bytes than this, we'll read another 16kB block
3051 onto it. If set too small, upload rate capacity will suffer. If set too high,
3052 memory will be wasted. The actual watermark may be lower than this in case
3053 the upload rate is low, this is the upper limit.
3055 ``auto_upload_slots`` defaults to true. When true, if there is a global upload
3056 limit set and the current upload rate is less than 90% of that, another upload
3057 slot is opened. If the upload rate has been saturated for an extended period
3058 of time, on upload slot is closed. The number of upload slots will never be
3059 less than what has been set by ``session::set_max_uploads()``. To query the
3060 current number of upload slots, see ``session_status::allowed_upload_slots``.
3062 ``use_parole_mode`` specifies if parole mode should be used. Parole mode means
3063 that peers that participate in pieces that fail the hash check are put in a mode
3064 where they are only allowed to download whole pieces. If the whole piece a peer
3065 in parole mode fails the hash check, it is banned. If a peer participates in a
3066 piece that passes the hash check, it is taken out of parole mode.
3068 ``cache_size`` is the disk write cache. It is specified in units of 16 KiB blocks.
3069 It defaults to 512 (= 8 MB).
3071 ``cache_expiry`` is the number of seconds from the last cached write to a piece
3072 in the write cache, to when it's forcefully flushed to disk. Default is 60 second.
3074 ``outgoing_ports``, if set to something other than (0, 0) is a range of ports
3075 used to bind outgoing sockets to. This may be useful for users whose router
3076 allows them to assign QoS classes to traffic based on its local port. It is
3077 a range instead of a single port because of the problems with failing to reconnect
3078 to peers if a previous socket to that peer and port is in ``TIME_WAIT`` state.
3080 ``peer_tos`` determines the TOS byte set in the IP header of every packet
3081 sent to peers (including web seeds). The default value for this is ``0x0``
3082 (no marking). One potentially useful TOS mark is ``0x20``, this represents
3083 the *QBone scavenger service*. For more details, see QBSS_.
3085 .. _`QBSS`: http://qbone.internet2.edu/qbss/
3087 ``active_downloads`` and ``active_seeds`` controls how many active seeding and
3088 downloading torrents the queuing mechanism allows. The target number of active
3089 torrents is ``max(active_downloads, active_seeds)``. ``active_downloads`` and
3090 ``active_seeds`` are upper limits on the number of downloading torrents and
3091 seeding torrents respectively. Setting the value to -1 will mean unlimited.
3093 For example if there are 10 seeding torrents and 10 downloading torrents, and
3094 ``active_downloads`` is 4 and ``active_seeds`` is 4, there will be no seed
3095 active, but 4 downloading torrents. If the settings are ``active_downloads`` = 2
3096 and ``active_seeds`` = 4, then there will be 2 downloading torrenst and 2 seeding
3097 torrents active. Torrents that are not auto managed are also counted against these
3098 limits. If there are non-auto managed torrents that use up all the slots, no
3099 auto managed torrent will be activated.
3101 if ``dont_count_slow_torrents`` is true, torrents without any payload transfers are
3102 not subject to the ``active_seeds`` and ``active_downloads`` limits. This is intended
3103 to make it more likely to utilize all available bandwidth, and avoid having torrents
3104 that don't transfer anything block the active slots.
3106 ``active_limit`` is a hard limit on the number of active seeds. This applies even to
3109 ``auto_manage_interval`` is the number of seconds between the torrent queue
3110 is updated, and rotated.
3112 ``share_ratio_limit`` is the upload / download ratio limit for considering a
3113 seeding torrent have met the seed limit criteria. See queuing_.
3115 ``seed_time_ratio_limit`` is the seeding time / downloading time ratio limit
3116 for considering a seeding torrent to have met the seed limit criteria. See queuing_.
3118 ``seed_time_limit`` is the limit on the time a torrent has been an active seed
3119 (specified in seconds) before it is considered having met the seed limit criteria.
3122 ``close_redundant_connections`` specifies whether libtorrent should close
3123 connections where both ends have no utility in keeping the connection open.
3124 For instance if both ends have completed their downloads, there's no point
3125 in keeping it open. This defaults to ``true``.
3127 ``auto_scrape_interval`` is the number of seconds between scrapes of
3128 queued torrents (auto managed and paused torrents). Auto managed
3129 torrents that are paused, are scraped regularly in order to keep
3130 track of their downloader/seed ratio. This ratio is used to determine
3131 which torrents to seed and which to pause.
3133 ``auto_scrape_min_interval`` is the minimum number of seconds between any
3134 automatic scrape (regardless of torrent). In case there are a large number
3135 of paused auto managed torrents, this puts a limit on how often a scrape
3138 ``max_peerlist_size`` is the maximum number of peers in the list of
3139 known peers. These peers are not necessarily connected, so this number
3140 should be much greater than the maximum number of connected peers.
3141 Peers are evicted from the cache when the list grows passed 90% of
3142 this limit, and once the size hits the limit, peers are no longer
3148 The ``pe_settings`` structure is used to control the settings related
3149 to peer protocol encryption::
3169 enc_policy out_enc_policy;
3170 enc_policy in_enc_policy;
3171 enc_level allowed_enc_level;
3176 ``in_enc_policy`` and ``out_enc_policy`` control the settings for incoming
3177 and outgoing connections respectively. The settings for these are:
3179 * ``forced`` - Only encrypted connections are allowed. Incoming connections
3180 that are not encrypted are closed and if the encrypted outgoing connection
3181 fails, a non-encrypted retry will not be made.
3183 * ``enabled`` - encrypted connections are enabled, but non-encrypted
3184 connections are allowed. An incoming non-encrypted connection will
3185 be accepted, and if an outgoing encrypted connection fails, a non-
3186 encrypted connection will be tried.
3188 * ``disabled`` - only non-encrypted connections are allowed.
3190 ``allowed_enc_level`` determines the encryption level of the
3191 connections. This setting will adjust which encryption scheme is
3192 offered to the other peer, as well as which encryption scheme is
3193 selected by the client. The settings are:
3195 * ``plaintext`` - only the handshake is encrypted, the bulk of the traffic
3198 * ``rc4`` - the entire stream is encrypted with RC4
3200 * ``both`` - both RC4 and plaintext connections are allowed.
3202 ``prefer_rc4`` can be set to true if you want to prefer the RC4 encrypted stream.
3208 The ``proxy_settings`` structs contains the information needed to
3209 direct certain traffic to a proxy.
3213 struct proxy_settings
3217 std::string hostname;
3220 std::string username;
3221 std::string password;
3236 ``hostname`` is the name or IP of the proxy server. ``port`` is the
3237 port number the proxy listens to. If required, ``username`` and ``password``
3238 can be set to authenticate with the proxy.
3240 The ``type`` tells libtorrent what kind of proxy server it is. The following
3241 options are available:
3243 * ``none`` - This is the default, no proxy server is used, all other fields
3246 * ``socks4`` - The server is assumed to be a `SOCKS4 server`_ that
3247 requires a username.
3249 * ``socks5`` - The server is assumed to be a SOCKS5 server (`RFC 1928`_) that
3250 does not require any authentication. The username and password are ignored.
3252 * ``socks5_pw`` - The server is assumed to be a SOCKS5 server that supports
3253 plain text username and password authentication (`RFC 1929`_). The username
3254 and password specified may be sent to the proxy if it requires.
3256 * ``http`` - The server is assumed to be an HTTP proxy. If the transport used
3257 for the connection is non-HTTP, the server is assumed to support the
3258 CONNECT_ method. i.e. for web seeds and HTTP trackers, a plain proxy will
3259 suffice. The proxy is assumed to not require authorization. The username
3260 and password will not be used.
3262 * ``http_pw`` - The server is assumed to be an HTTP proxy that requires
3263 user authorization. The username and password will be sent to the proxy.
3265 .. _`SOCKS4 server`: http://www.ufasoft.com/doc/socks4_protocol.htm
3266 .. _`RFC 1928`: http://www.faqs.org/rfcs/rfc1928.html
3267 .. _`RFC 1929`: http://www.faqs.org/rfcs/rfc1929.html
3268 .. _CONNECT: draft-luotonen-web-proxy-tunneling-01.txt
3273 The ``ip_filter`` class is a set of rules that uniquely categorizes all
3274 ip addresses as allowed or disallowed. The default constructor creates
3275 a single rule that allows all addresses (0.0.0.0 - 255.255.255.255 for
3276 the IPv4 range, and the equivalent range covering all addresses for the
3281 template <class Addr>
3292 enum access_flags { blocked = 1 };
3295 void add_rule(address first, address last, int flags);
3296 int access(address const& addr) const;
3298 typedef boost::tuple<std::vector<ip_range<address_v4> >
3299 , std::vector<ip_range<address_v6> > > filter_tuple_t;
3301 filter_tuple_t export_filter() const;
3312 Creates a default filter that doesn't filter any address.
3315 ``access(x) == 0`` for every ``x``
3323 void add_rule(address first, address last, int flags);
3325 Adds a rule to the filter. ``first`` and ``last`` defines a range of
3326 ip addresses that will be marked with the given flags. The ``flags``
3327 can currently be 0, which means allowed, or ``ip_filter::blocked``, which
3331 ``first.is_v4() == last.is_v4() && first.is_v6() == last.is_v6()``
3334 ``access(x) == flags`` for every ``x`` in the range [``first``, ``last``]
3336 This means that in a case of overlapping ranges, the last one applied takes
3345 int access(address const& addr) const;
3347 Returns the access permissions for the given address (``addr``). The permission
3348 can currently be 0 or ``ip_filter::blocked``. The complexity of this operation
3349 is O(``log`` n), where n is the minimum number of non-overlapping ranges to describe
3358 boost::tuple<std::vector<ip_range<address_v4> >
3359 , std::vector<ip_range<address_v6> > > export_filter() const;
3361 This function will return the current state of the filter in the minimum number of
3362 ranges possible. They are sorted from ranges in low addresses to high addresses. Each
3363 entry in the returned vector is a range with the access control specified in its
3366 The return value is a tuple containing two range-lists. One for IPv4 addresses
3367 and one for IPv6 addresses.
3373 Both the ``peer_id`` and ``sha1_hash`` types are typedefs of the class
3374 ``big_number``. It represents 20 bytes of data. Its synopsis follows::
3379 bool operator==(const big_number& n) const;
3380 bool operator!=(const big_number& n) const;
3381 bool operator<(const big_number& n) const;
3383 const unsigned char* begin() const;
3384 const unsigned char* end() const;
3386 unsigned char* begin();
3387 unsigned char* end();
3390 The iterators gives you access to individual bytes.
3396 The bitfiled type stores any number of bits as a bitfield in an array.
3404 bitfield(int bits, bool val);
3405 bitfield(char const* bytes, int bits);
3406 bitfield(bitfield const& rhs);
3408 void borrow_bytes(char* bytes, int bits);
3411 void assign(char const* bytes, int bits);
3413 bool operator[](int index) const;
3415 bool get_bit(int index) const;
3417 void clear_bit(int index);
3418 void set_bit(int index);
3420 std::size_t size() const;
3423 char const* bytes() const;
3425 bitfield& operator=(bitfield const& rhs);
3429 typedef const_iterator;
3430 const_iterator begin() const;
3431 const_iterator end() const;
3433 void resize(int bits, bool val);
3436 void resize(int bits);
3444 This class creates sha1-hashes. Its declaration looks like this::
3450 hasher(char const* data, unsigned int len);
3452 void update(char const* data, unsigned int len);
3458 You use it by first instantiating it, then call ``update()`` to feed it
3459 with data. i.e. you don't have to keep the entire buffer of which you want to
3460 create the hash in memory. You can feed the hasher parts of it at a time. When
3461 You have fed the hasher with all the data, you call ``final()`` and it
3462 will return the sha1-hash of the data.
3464 The constructor that takes a ``char const*`` and an integer will construct the
3465 sha1 context and feed it the data passed in.
3467 If you want to reuse the hasher object once you have created a hash, you have to
3468 call ``reset()`` to reinitialize it.
3470 The sha1-algorithm used was implemented by Steve Reid and released as public domain.
3471 For more info, see ``src/sha1.cpp``.
3477 The fingerprint class represents information about a client and its version. It is used
3478 to encode this information into the client's peer id.
3480 This is the class declaration::
3484 fingerprint(const char* id_string, int major, int minor
3485 , int revision, int tag);
3487 std::string to_string() const;
3492 char revision_version;
3497 The constructor takes a ``char const*`` that should point to a string constant containing
3498 exactly two characters. These are the characters that should be unique for your client. Make
3499 sure not to clash with anybody else. Here are some taken id's:
3501 +----------+-----------------------+
3502 | id chars | client |
3503 +==========+=======================+
3505 +----------+-----------------------+
3506 | 'LT' | libtorrent (default) |
3507 +----------+-----------------------+
3508 | 'BX' | BittorrentX |
3509 +----------+-----------------------+
3510 | 'MT' | Moonlight Torrent |
3511 +----------+-----------------------+
3512 | 'TS' | Torrent Storm |
3513 +----------+-----------------------+
3514 | 'SS' | Swarm Scope |
3515 +----------+-----------------------+
3516 | 'XT' | Xan Torrent |
3517 +----------+-----------------------+
3519 There's currently an informal directory of client id's here__.
3521 __ http://wiki.theory.org/BitTorrentSpecification#peer_id
3524 The ``major``, ``minor``, ``revision`` and ``tag`` parameters are used to identify the
3525 version of your client. All these numbers must be within the range [0, 9].
3527 ``to_string()`` will generate the actual string put in the peer-id, and return it.
3533 The ``upnp`` and ``natpmp`` classes contains the state for all UPnP and NAT-PMP mappings,
3534 by default 1 or two mappings are made by libtorrent, one for the listen port and one
3535 for the DHT port (UDP).
3543 enum protocol_type { none = 0, udp = 1, tcp = 2 };
3544 int add_mapping(protocol_type p, int external_port, int local_port);
3545 void delete_mapping(int mapping_index);
3547 void discover_device();
3550 std::string router_model();
3557 enum protocol_type { none = 0, udp = 1, tcp = 2 };
3558 int add_mapping(protocol_type p, int external_port, int local_port);
3559 void delete_mapping(int mapping_index);
3562 void rebind(address const& listen_interface);
3565 ``discover_device()``, ``close()`` and ``rebind()`` are for internal uses and should
3566 not be called directly by clients.
3573 int add_mapping(protocol_type p, int external_port, int local_port);
3575 Attempts to add a port mapping for the specified protocol. Valid protocols are
3576 ``upnp::tcp`` and ``upnp::udp`` for the UPnP class and ``natpmp::tcp`` and
3577 ``natpmp::udp`` for the NAT-PMP class.
3579 ``external_port`` is the port on the external address that will be mapped. This
3580 is a hint, you are not guaranteed that this port will be available, and it may
3581 end up being something else. In the portmap_alert_ notification, the actual
3582 external port is reported.
3584 ``local_port`` is the port in the local machine that the mapping should forward
3587 The return value is an index that identifies this port mapping. This is used
3588 to refer to mappings that fails or succeeds in the portmap_error_alert_ and
3589 portmap_alert_ respectively. If The mapping fails immediately, the return value
3590 is -1, which means failure. There will not be any error alert notification for
3591 mappings that fail with a -1 return value.
3598 void delete_mapping(int mapping_index);
3600 This function removes a port mapping. ``mapping_index`` is the index that refers
3601 to the mapping you want to remove, which was returned from add_mapping_.
3608 std::string router_model();
3610 This is only available for UPnP routers. If the model is advertized by
3611 the router, it can be queried through this function.
3622 std::string identify_client(peer_id const& id);
3624 This function is declared in the header ``<libtorrent/identify_client.hpp>``. It can can be used
3625 to extract a string describing a client version from its peer-id. It will recognize most clients
3626 that have this kind of identification in the peer-id.
3629 client_fingerprint()
3630 --------------------
3634 boost::optional<fingerprint> client_fingerprint(peer_id const& p);
3636 Returns an optional fingerprint if any can be identified from the peer id. This can be used
3637 to automate the identification of clients. It will not be able to identify peers with non-
3638 standard encodings. Only Azureus style, Shadow's style and Mainline style. This function is
3639 declared in the header ``<libtorrent/identify_client.hpp>``.
3647 template<class InIt> entry bdecode(InIt start, InIt end);
3648 template<class OutIt> void bencode(OutIt out, const entry& e);
3651 These functions will encode data to bencoded_ or decode bencoded_ data.
3653 .. _bencoded: http://wiki.theory.org/index.php/BitTorrentSpecification
3655 The entry_ class is the internal representation of the bencoded data
3656 and it can be used to retrieve information, an entry_ can also be build by
3657 the program and given to ``bencode()`` to encode it into the ``OutIt``
3660 The ``OutIt`` and ``InIt`` are iterators
3661 (InputIterator_ and OutputIterator_ respectively). They
3662 are templates and are usually instantiated as ostream_iterator_,
3663 back_insert_iterator_ or istream_iterator_. These
3664 functions will assume that the iterator refers to a character
3665 (``char``). So, if you want to encode entry ``e`` into a buffer
3666 in memory, you can do it like this::
3668 std::vector<char> buffer;
3669 bencode(std::back_inserter(buf), e);
3671 .. _InputIterator: http://www.sgi.com/tech/stl/InputIterator.html
3672 .. _OutputIterator: http://www.sgi.com/tech/stl/OutputIterator.html
3673 .. _ostream_iterator: http://www.sgi.com/tech/stl/ostream_iterator.html
3674 .. _back_insert_iterator: http://www.sgi.com/tech/stl/back_insert_iterator.html
3675 .. _istream_iterator: http://www.sgi.com/tech/stl/istream_iterator.html
3677 If you want to decode a torrent file from a buffer in memory, you can do it like this::
3679 std::vector<char> buffer;
3681 entry e = bdecode(buf.begin(), buf.end());
3683 Or, if you have a raw char buffer::
3687 entry e = bdecode(buf, buf + data_size);
3689 Now we just need to know how to retrieve information from the entry_.
3691 If ``bdecode()`` encounters invalid encoded data in the range given to it
3692 it will throw invalid_encoding_.
3698 The ``pop_alert()`` function on session is the interface for retrieving
3699 alerts, warnings, messages and errors from libtorrent. If no alerts have
3700 been posted by libtorrent ``pop_alert()`` will return a default initialized
3701 ``auto_ptr`` object. If there is an alert in libtorrent's queue, the alert
3702 from the front of the queue is popped and returned.
3703 You can then use the alert object and query
3705 By default, only errors are reported. ``session::set_alert_mask()`` can be
3706 used to specify which kinds of events should be reported. The alert mask
3707 is a bitmask with the following bits:
3709 +--------------------------------+---------------------------------------------------------------------+
3710 | ``error_notification`` | Enables alerts that report an error. This includes: |
3712 | | * tracker errors |
3713 | | * tracker warnings |
3715 | | * resume data failures |
3716 | | * web seed errors |
3717 | | * .torrent files errors |
3718 | | * listen socket errors |
3719 | | * port mapping errors |
3720 +--------------------------------+---------------------------------------------------------------------+
3721 | ``peer_notification`` | Enables alerts when peers send invalid requests, get banned or |
3723 +--------------------------------+---------------------------------------------------------------------+
3724 | ``port_mapping_notification`` | Enables alerts for port mapping events. For NAT-PMP and UPnP. |
3725 +--------------------------------+---------------------------------------------------------------------+
3726 | ``storage_notification`` | Enables alerts for events related to the storage. File errors and |
3727 | | synchronization events for moving the storage, renaming files etc. |
3728 +--------------------------------+---------------------------------------------------------------------+
3729 | ``tracker_notification`` | Enables all tracker events. Includes announcing to trackers, |
3730 | | receiving responses, warnings and errors. |
3731 +--------------------------------+---------------------------------------------------------------------+
3732 | ``debug_notification`` | Low level alerts for when peers are connected and disconnected. |
3733 +--------------------------------+---------------------------------------------------------------------+
3734 | ``status_notification`` | Enables alerts for when a torrent or the session changes state. |
3735 +--------------------------------+---------------------------------------------------------------------+
3736 | ``progress_notification`` | Alerts for when blocks are requested and completed. Also when |
3737 | | pieces are completed. |
3738 +--------------------------------+---------------------------------------------------------------------+
3739 | ``ip_block_notification`` | Alerts when a peer is blocked by the ip blocker or port blocker. |
3740 +--------------------------------+---------------------------------------------------------------------+
3741 | ``all_categories`` | The full bitmask, representing all available categories. |
3742 +--------------------------------+---------------------------------------------------------------------+
3744 Every alert belongs to one or more category. There is a small cost involved in posting alerts. Only
3745 alerts that belong to an enabled category are posted. Setting the alert bitmask to 0 will disable
3748 When you get an alert, you can use ``typeid()`` or ``dynamic_cast<>`` to get more detailed
3749 information on exactly which type it is. i.e. what kind of error it is. You can also use a
3750 dispatcher_ mechanism that's available in libtorrent.
3752 All alert types are defined in the ``<libtorrent/alert_types.hpp>`` header file.
3754 The ``alert`` class is the base class that specific messages are derived from. This
3765 error_notification = *implementation defined*,
3766 peer_notification = *implementation defined*,
3767 port_mapping_notification = *implementation defined*,
3768 storage_notification = *implementation defined*,
3769 tracker_notification = *implementation defined*,
3770 debug_notification = *implementation defined*,
3771 status_notification = *implementation defined*,
3772 progress_notification = *implementation defined*,
3773 ip_block_notification = *implementation defined*,
3775 all_categories = *implementation defined*
3778 ptime timestamp() const;
3782 virtual std::string message() const = 0;
3783 virtual char const* what() const = 0;
3784 virtual int category() const = 0;
3785 virtual std::auto_ptr<alert> clone() const = 0;
3788 ``what()`` returns a string literal describing the type of the alert. It does
3789 not include any information that might be bundled with the alert.
3791 ``category()`` returns a bitmask specifying which categories this alert belong to.
3793 ``clone()`` returns a pointer to a copy of the alert.
3795 ``message()`` generate a string describing the alert and the information bundled
3796 with it. This is mainly intended for debug and development use. It is not suitable
3797 to use this for applications that may be localized. Instead, handle each alert
3798 type individually and extract and render the information from the alert depending
3801 There's another alert base class that most alerts derives from, all the
3802 alerts that are generated for a specific torrent are derived from::
3804 struct torrent_alert: alert
3807 torrent_handle handle;
3810 There's also a base class for all alerts referring to tracker events::
3812 struct tracker_alert: torrent_alert
3818 The specific alerts are:
3823 Whenever libtorrent learns about the machines external IP, this alert is
3824 generated. The external IP address can be acquired from the tracker (if it
3825 supports that) or from peers that supports the extension protocol.
3826 The address can be accessed through the ``external_address`` member.
3830 struct external_ip_alert: alert
3833 address external_address;
3840 This alert is generated when none of the ports, given in the port range, to
3841 session_ can be opened for listening. This alert doesn't have any extra
3848 This alert is generated when a NAT router was successfully found but some
3849 part of the port mapping request failed. It contains a text message that
3850 may help the user figure out what is wrong. This alert is not generated in
3851 case it appears the client is not running on a NAT:ed network or if it
3852 appears there is no NAT router that can be remote controlled to add port
3855 ``mapping`` refers to the mapping index of the port map that failed, i.e.
3856 the index returned from add_mapping_.
3858 ``type`` is 0 for NAT-PMP and 1 for UPnP.
3862 struct portmap_error_alert: alert
3872 This alert is generated when a NAT router was successfully found and
3873 a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP
3874 capable router, this is typically generated once when mapping the TCP
3875 port and, if DHT is enabled, when the UDP port is mapped.
3877 ``mapping`` refers to the mapping index of the port map that failed, i.e.
3878 the index returned from add_mapping_.
3880 ``external_port`` is the external port allocated for the mapping.
3882 ``type`` is 0 for NAT-PMP and 1 for UPnP.
3886 struct portmap_alert: alert
3897 If the storage fails to read or write files that it needs access to, this alert is
3898 generated and the torrent is paused.
3900 ``file`` is the path to the file that was accessed when the error occurred.
3902 ``msg`` is the error message received from the OS.
3906 struct file_error_alert: torrent_alert
3914 tracker_announce_alert
3915 ----------------------
3917 This alert is generated each time a tracker announce is sent (or attempted to be sent).
3918 There are no extra data members in this alert. The url can be found in the base class
3923 struct tracker_announce_alert: tracker_alert
3929 Event specifies what event was sent to the tracker. It is defined as:
3940 This alert is generated on tracker time outs, premature disconnects, invalid response or
3941 a HTTP response other than "200 OK". From the alert you can get the handle to the torrent
3942 the tracker belongs to.
3944 The ``times_in_row`` member says how many times in a row this tracker has failed.
3945 ``status_code`` is the code returned from the HTTP server. 401 means the tracker needs
3946 authentication, 404 means not found etc. If the tracker timed out, the code will be set
3951 struct tracker_error_alert: tracker_alert
3962 This alert is only for informational purpose. It is generated when a tracker announce
3963 succeeds. It is generated regardless what kind of tracker was used, be it UDP, HTTP or
3968 struct tracker_reply_alert: tracker_alert
3974 The ``num_peers`` tells how many peers were returned from the tracker. This is
3975 not necessarily all new peers, some of them may already be connected.
3980 This alert is generated each time the DHT receives peers from a node. ``num_peers``
3981 is the number of peers we received in this packet. Typically these packets are
3982 received from multiple DHT nodes, and so the alerts are typically generated
3987 struct dht_reply_alert: tracker_alert
3994 tracker_warning_alert
3995 ---------------------
3997 This alert is triggered if the tracker reply contains a warning field. Usually this
3998 means that the tracker announce was successful, but the tracker has a message to
3999 the client. The ``msg`` string in the alert contains the warning message from
4004 struct tracker_warning_alert: tracker_alert
4013 This alert is generated when a scrape request succeeds. ``incomplete``
4014 and ``complete`` is the data returned in the scrape response. These numbers
4015 may be -1 if the reponse was malformed.
4019 struct scrape_reply_alert: tracker_alert
4030 If a scrape request fails, this alert is generated. This might be due
4031 to the tracker timing out, refusing connection or returning an http response
4032 code indicating an error. ``msg`` contains a message describing the error.
4036 struct scrape_failed_alert: tracker_alert
4045 This alert is generated when a HTTP seed name lookup fails.
4047 It contains ``url`` to the HTTP seed that failed along with an error message.
4051 struct url_seed_alert: torrent_alert
4061 This alert is generated when a finished piece fails its hash check. You can get the handle
4062 to the torrent which got the failed piece and the index of the piece itself from the alert.
4066 struct hash_failed_alert: torrent_alert
4076 This alert is generated when a peer is banned because it has sent too many corrupt pieces
4077 to us. ``ip`` is the endpoint to the peer that was banned.
4081 struct peer_ban_alert: torrent_alert
4084 asio::ip::tcp::endpoint ip;
4091 This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer
4092 will be disconnected, but you get its ip address from the alert, to identify it.
4096 struct peer_error_alert: torrent_alert
4099 asio::ip::tcp::endpoint ip;
4104 invalid_request_alert
4105 ---------------------
4107 This is a debug alert that is generated by an incoming invalid piece request.
4108 ``Ƭp`` is the address of the peer and the ``request`` is the actual incoming
4109 request from the peer.
4113 struct invalid_request_alert: torrent_alert
4115 invalid_request_alert(
4116 peer_request const& r
4117 , torrent_handle const& h
4118 , asio::ip::tcp::endpoint const& send
4119 , peer_id const& pid
4120 , std::string const& msg);
4122 virtual std::auto_ptr<alert> clone() const;
4124 asio::ip::tcp::endpoint ip;
4125 peer_request request;
4135 bool operator==(peer_request const& r) const;
4139 The ``peer_request`` contains the values the client sent in its ``request`` message. ``piece`` is
4140 the index of the piece it want data from, ``start`` is the offset within the piece where the data
4141 should be read, and ``length`` is the amount of data it wants.
4143 torrent_finished_alert
4144 ----------------------
4146 This alert is generated when a torrent switches from being a downloader to a seed.
4147 It will only be generated once per torrent. It contains a torrent_handle to the
4148 torrent in question.
4150 There are no additional data members in this alert.
4153 metadata_failed_alert
4154 ---------------------
4156 This alert is generated when the metadata has been completely received and the info-hash
4157 failed to match it. i.e. the metadata that was received was corrupt. libtorrent will
4158 automatically retry to fetch it in this case. This is only relevant when running a
4159 torrent-less download, with the metadata extension provided by libtorrent.
4161 There are no additional data members in this alert.
4164 metadata_received_alert
4165 -----------------------
4167 This alert is generated when the metadata has been completely received and the torrent
4168 can start downloading. It is not generated on torrents that are started with metadata, but
4169 only those that needs to download it from peers (when utilizing the libtorrent extension).
4171 There are no additional data members in this alert.
4174 fastresume_rejected_alert
4175 -------------------------
4177 This alert is generated when a fastresume file has been passed to ``add_torrent`` but the
4178 files on disk did not match the fastresume file. The string explains the reason why the
4179 resume file was rejected.
4183 struct fastresume_rejected_alert: torrent_alert
4193 This alert is generated when a peer is blocked by the IP filter. The ``ip`` member is the
4194 address that was blocked.
4198 struct peer_blocked_alert: alert
4208 The ``storage_moved_alert`` is generated when all the disk IO has completed and the
4209 files have been moved, as an effect of a call to ``torrent_handle::move_storage``. This
4210 is useful to synchronize with the actual disk. The ``path`` member is the new path of
4215 struct storage_moved_alert: torrent_alert
4222 torrent_paused_alert
4223 --------------------
4225 This alert is generated as a response to a ``torrent_handle::pause`` request. It is
4226 generated once all disk IO is complete and the files in the torrent have been closed.
4227 This is useful for synchronizing with the disk.
4229 There are no additional data members in this alert.
4231 torrent_resumed_alert
4232 ---------------------
4234 This alert is generated as a response to a ``torrent_handle::resume`` request. It is
4235 generated when a torrent goes from a paused state to an active state.
4237 There are no additional data members in this alert.
4239 save_resume_data_alert
4240 ----------------------
4242 This alert is generated as a response to a ``torrent_handle::save_resume_data`` request.
4243 It is generated once the disk IO thread is done writing the state for this torrent.
4244 The ``resume_data`` member points to the resume data.
4248 struct save_resume_data_alert: torrent_alert
4251 boost::shared_ptr<entry> resume_data;
4254 save_resume_data_failed_alert
4255 -----------------------------
4257 This alert is generated instead of ``save_resume_data_alert`` if there was an error
4258 generating the resume data. ``msg`` describes what went wrong.
4262 struct save_resume_data_failed_alert: torrent_alert
4271 The ``handle_alert`` class is defined in ``<libtorrent/alert.hpp>``.
4277 void operator()(portmap_error_alert const& a)
4279 std::cout << "Portmapper: " << a.msg << std::endl;
4282 void operator()(tracker_warning_alert const& a)
4284 std::cout << "Tracker warning: " << a.msg << std::endl;
4287 void operator()(torrent_finished_alert const& a)
4289 // write fast resume data
4292 std::cout << a.handle.get_torrent_info().name() << "completed"
4299 std::auto_ptr<alert> a;
4300 a = ses.pop_alert();
4304 handle_alert<portmap_error_alert
4305 , tracker_warning_alert
4306 , torrent_finished_alert
4307 >::handle_alert(h, a);
4308 a = ses.pop_alert();
4311 In this example 3 alert types are used. You can use any number of template
4312 parameters to select between more types. If the number of types are more than
4313 15, you can define ``TORRENT_MAX_ALERT_TYPES`` to a greater number before
4314 including ``<libtorrent/alert.hpp>``.
4320 There are a number of exceptions that can be thrown from different places in libtorrent,
4321 here's a complete list with description.
4327 This exception is thrown when querying information from a torrent_handle_ that hasn't
4328 been initialized or that has become invalid.
4332 struct invalid_handle: std::exception
4334 const char* what() const throw();
4341 This is thrown by `add_torrent()`_ if the torrent already has been added to
4342 the session. Since `remove_torrent()`_ is asynchronous, this exception may
4343 be thrown if the torrent is removed and then immediately added again.
4347 struct duplicate_torrent: std::exception
4349 const char* what() const throw();
4356 This is thrown by ``bdecode()`` if the input data is not a valid bencoding.
4360 struct invalid_encoding: std::exception
4362 const char* what() const throw();
4369 This is thrown from the accessors of ``entry`` if the data type of the ``entry`` doesn't
4370 match the type you want to extract from it.
4374 struct type_error: std::runtime_error
4376 type_error(const char* error);
4380 invalid_torrent_file
4381 --------------------
4383 This exception is thrown from the constructor of ``torrent_info`` if the given bencoded information
4384 doesn't meet the requirements on what information has to be present in a torrent file.
4388 struct invalid_torrent_file: std::exception
4390 const char* what() const throw();
4397 The storage interface is a pure virtual class that can be implemented to
4398 change the behavior of the actual file storage. The interface looks like
4401 struct storage_interface
4403 virtual void initialize(bool allocate_files) = 0;
4404 virtual size_type read(char* buf, int slot, int offset, int size) = 0;
4405 virtual void write(const char* buf, int slot, int offset, int size) = 0;
4406 virtual bool move_storage(fs::path save_path) = 0;
4407 virtual bool verify_resume_data(lazy_entry& rd, std::string& error) = 0;
4408 virtual void write_resume_data(entry& rd) const = 0;
4409 virtual void move_slot(int src_slot, int dst_slot) = 0;
4410 virtual void swap_slots(int slot1, int slot2) = 0;
4411 virtual void swap_slots3(int slot1, int slot2, int slot3) = 0;
4412 virtual sha1_hash hash_for_slot(int slot, partial_hash& h, int piece_size) = 0;
4413 virtual void release_files() = 0;
4414 virtual void delete_files() = 0;
4415 virtual ~storage_interface() {}
4424 void initialize(bool allocate_files) = 0;
4426 This function is called when the storage is to be initialized. The default storage
4427 will create directories and empty files at this point. If ``allocate_files`` is true,
4428 it will also ``ftruncate`` all files to their target size.
4436 size_type read(char* buf, int slot, int offset, int size) = 0;
4438 This function should read the data in the given slot and at the given offset
4439 and ``size`` number of bytes. The data is to be copied to ``buf``.
4441 The return value is the number of bytes actually read.
4449 void write(const char* buf, int slot, int offset, int size) = 0;
4451 This function should write the data in ``buf`` to the given slot (``slot``) at offset
4452 ``offset`` in that slot. The buffer size is ``size``.
4460 bool move_storage(fs::path save_path) = 0;
4462 This function should move all the files belonging to the storage to the new save_path.
4463 The default storage moves the single file or the directory of the torrent.
4465 Before moving the files, any open file handles may have to be closed, like
4466 ``release_files()``.
4469 verify_resume_data()
4470 --------------------
4474 bool verify_resume_data(entry& rd, std::string& error) = 0;
4476 This function should verify the resume data ``rd`` with the files
4477 on disk. If the resume data seems to be up-to-date, return true. If
4478 not, set ``error`` to a description of what mismatched and return false.
4480 The default storage may compare file sizes and time stamps of the files.
4488 void write_resume_data(entry& rd) const = 0;
4490 This function should fill in resume data, the current state of the
4491 storage, in ``rd``. The default storage adds file timestamps and
4500 void move_slot(int src_slot, int dst_slot) = 0;
4502 This function should copy or move the data in slot ``src_slot`` to
4503 the slot ``dst_slot``. This is only used in compact mode.
4505 If the storage caches slots, this could be implemented more
4506 efficient than reading and writing the data.
4514 void swap_slots(int slot1, int slot2) = 0;
4516 This function should swap the data in ``slot1`` and ``slot2``. The default
4517 storage uses a scratch buffer to read the data into, then moving the other
4518 slot and finally writing back the temporary slot's data
4520 This is only used in compact mode.
4528 void swap_slots3(int slot1, int slot2, int slot3) = 0;
4530 This function should do a 3-way swap, or shift of the slots. ``slot1``
4531 should move to ``slot2``, which should be moved to ``slot3`` which in turn
4532 should be moved to ``slot1``.
4534 This is only used in compact mode.
4542 sha1_hash hash_for_slot(int slot, partial_hash& h, int piece_size) = 0;
4544 The function should read the remaining bytes of the slot and hash it with the
4545 sha-1 state in ``partion_hash``. The ``partial_hash`` struct looks like this::
4554 ``offset`` is the number of bytes in the slot that has already been hashed, and
4555 ``h`` is the sha-1 state of that hash. ``piece_size`` is the size of the piece
4556 that is stored in the given slot.
4558 The function should return the hash of the piece stored in the slot.
4566 void release_files() = 0;
4568 This function should release all the file handles that it keeps open to files
4569 belonging to this storage. The default implementation just calls
4570 ``file_pool::release_files(this)``.
4578 void delete_files() = 0;
4580 This function should delete all files and directories belonging to this storage.
4586 libtorrent supports *queuing*. Which means it makes sure that a limited number of
4587 torrents are being downloaded at any given time, and once a torrent is completely
4588 downloaded, the next in line is started.
4590 Torrents that are *auto managed* are subject to the queuing and the active torrents
4591 limits. To make a torrent auto managed, set ``auto_managed`` to true when adding the
4592 torrent (see `add_torrent()`_).
4594 The limits of the number of downloading and seeding torrents are controlled via
4595 ``active_downloads``, ``active_seeds`` and ``active_limit`` in session_settings_.
4596 These limits takes non auto managed torrents into account as well. If there are
4597 more non-auto managed torrents being downloaded than the ``active_downloads``
4598 setting, any auto managed torrents will be queued until torrents are removed so
4599 that the number drops below the limit.
4601 The default values are 8 active downloads and 5 active seeds.
4603 At a regular interval, torrents are checked if there needs to be any re-ordering of
4604 which torrents are active and which are queued. This interval can be controlled via
4605 ``auto_manage_interval`` in session_settings_. It defaults to every 30 seconds.
4607 For queuing to work, resume data needs to be saved and restored for all torrents.
4608 See `save_resume_data()`_.
4613 Torrents that are currently being downloaded or incomplete (with bytes still to download)
4614 are queued. The torrents in the front of the queue are started to be actively downloaded
4615 and the rest are ordered with regards to their queue position. Any newly added torrent
4616 is placed at the end of the queue. Once a torrent is removed or turns into a seed, its
4617 queue position is -1 and all torrents that used to be after it in the queue, decreases their
4618 position in order to fill the gap.
4620 The queue positions are always in a sequence without any gaps.
4622 Lower queue position means closer to the front of the queue, and will be started sooner than
4623 torrents with higher queue positions.
4625 To query a torrent for its position in the queue, or change its position, see:
4626 `queue_position() queue_position_up() queue_position_down() queue_position_top() queue_position_bottom()`_.
4631 Auto managed seeding torrents are rotated, so that all of them are allocated a fair
4632 amount of seeding. Torrents with fewer completed *seed cycles* are prioritized for
4633 seeding. A seed cycle is completed when a torrent meets either the share ratio limit
4634 (uploaded bytes / downloaded bytes), the share time ratio (time seeding / time
4635 downloaing) or seed time limit (time seeded).
4637 The relevant settings to control these limits are ``share_ratio_limit``,
4638 ``seed_time_ratio_limit`` and ``seed_time_limit`` in session_settings_.
4644 The fast resume mechanism is a way to remember which pieces are downloaded
4645 and where they are put between sessions. You can generate fast resume data by
4646 calling `save_resume_data()`_ on torrent_handle_. You can
4647 then save this data to disk and use it when resuming the torrent. libtorrent
4648 will not check the piece hashes then, and rely on the information given in the
4649 fast-resume data. The fast-resume data also contains information about which
4650 blocks, in the unfinished pieces, were downloaded, so it will not have to
4651 start from scratch on the partially downloaded pieces.
4653 To use the fast-resume data you simply give it to `add_torrent()`_, and it
4654 will skip the time consuming checks. It may have to do the checking anyway, if
4655 the fast-resume data is corrupt or doesn't fit the storage for that torrent,
4656 then it will not trust the fast-resume data and just do the checking.
4661 The file format is a bencoded dictionary containing the following fields:
4663 +----------------------+--------------------------------------------------------------+
4664 | ``file-format`` | string: "libtorrent resume file" |
4666 +----------------------+--------------------------------------------------------------+
4667 | ``file-version`` | integer: 1 |
4669 +----------------------+--------------------------------------------------------------+
4670 | ``info-hash`` | string, the info hash of the torrent this data is saved for. |
4672 +----------------------+--------------------------------------------------------------+
4673 | ``blocks per piece`` | integer, the number of blocks per piece. Must be: piece_size |
4674 | | / (16 * 1024). Clamped to be within the range [1, 256]. It |
4675 | | is the number of blocks per (normal sized) piece. Usually |
4676 | | each block is 16 * 1024 bytes in size. But if piece size is |
4677 | | greater than 4 megabytes, the block size will increase. |
4679 +----------------------+--------------------------------------------------------------+
4680 | ``pieces`` | A string with piece flags, one character per piece. |
4681 | | Bit 1 means we have that piece. |
4682 +----------------------+--------------------------------------------------------------+
4683 | ``slots`` | list of integers. The list maps slots to piece indices. It |
4684 | | tells which piece is on which slot. If piece index is -2 it |
4685 | | means it is free, that there's no piece there. If it is -1, |
4686 | | means the slot isn't allocated on disk yet. The pieces have |
4687 | | to meet the following requirement: |
4689 | | If there's a slot at the position of the piece index, |
4690 | | the piece must be located in that slot. |
4692 +----------------------+--------------------------------------------------------------+
4693 | ``peers`` | list of dictionaries. Each dictionary has the following |
4696 | | +----------+-----------------------------------------------+ |
4697 | | | ``ip`` | string, the ip address of the peer. This is | |
4698 | | | | not a binary representation of the ip | |
4699 | | | | address, but the string representation. It | |
4700 | | | | may be an IPv6 string or an IPv4 string. | |
4701 | | +----------+-----------------------------------------------+ |
4702 | | | ``port`` | integer, the listen port of the peer | |
4703 | | +----------+-----------------------------------------------+ |
4705 | | These are the local peers we were connected to when this |
4706 | | fast-resume data was saved. |
4708 +----------------------+--------------------------------------------------------------+
4709 | ``unfinished`` | list of dictionaries. Each dictionary represents an |
4710 | | piece, and has the following layout: |
4712 | | +-------------+--------------------------------------------+ |
4713 | | | ``piece`` | integer, the index of the piece this entry | |
4714 | | | | refers to. | |
4715 | | +-------------+--------------------------------------------+ |
4716 | | | ``bitmask`` | string, a binary bitmask representing the | |
4717 | | | | blocks that have been downloaded in this | |
4719 | | +-------------+--------------------------------------------+ |
4720 | | | ``adler32`` | The adler32 checksum of the data in the | |
4721 | | | | blocks specified by ``bitmask``. | |
4723 | | +-------------+--------------------------------------------+ |
4725 +----------------------+--------------------------------------------------------------+
4726 | ``file sizes`` | list where each entry corresponds to a file in the file list |
4727 | | in the metadata. Each entry has a list of two values, the |
4728 | | first value is the size of the file in bytes, the second |
4729 | | is the time stamp when the last time someone wrote to it. |
4730 | | This information is used to compare with the files on disk. |
4731 | | All the files must match exactly this information in order |
4732 | | to consider the resume data as current. Otherwise a full |
4733 | | re-check is issued. |
4734 +----------------------+--------------------------------------------------------------+
4735 | ``allocation`` | The allocation mode for the storage. Can be either ``full`` |
4736 | | or ``compact``. If this is full, the file sizes and |
4737 | | timestamps are disregarded. Pieces are assumed not to have |
4738 | | moved around even if the files have been modified after the |
4739 | | last resume data checkpoint. |
4740 +----------------------+--------------------------------------------------------------+
4745 libtorrent starts 2 or 3 threads.
4747 * The first thread is the main thread that will sit
4748 idle in a ``select()`` call most of the time. This thread runs the main loop
4749 that will send and receive data on all connections.
4751 * The second thread is a hash-check thread. Whenever a torrent is added it will
4752 first be passed to this thread for checking the files that may already have been
4753 downloaded. If there is any resume data this thread will make sure it is valid
4754 and matches the files. Once the torrent has been checked, it is passed on to the
4755 main thread that will start it. The hash-check thread has a queue of torrents,
4756 it will only check one torrent at a time.
4758 * The third thread is spawned by asio on systems that don't support
4759 non-blocking host name resolution to simulate non-blocking behavior.
4765 There are three modes in which storage (files on disk) are allocated in libtorrent.
4767 1. The traditional *full allocation* mode, where the entire files are filled up with
4768 zeros before anything is downloaded. libtorrent will look for sparse files support
4769 in the filesystem that is used for storage, and use sparse files or file system
4770 zero fill support if present. This means that on NTFS, full allocation mode will
4771 only allocate storage for the downloaded pieces.
4773 2. The *compact allocation* mode, where only files are allocated for actual
4774 pieces that have been downloaded. This is the default allocation mode in libtorrent.
4776 3. The *sparce allocation*, sparse files are used, and pieces are downloaded directly
4777 to where they belong. This is the recommended (and default) mode.
4779 The allocation mode is selected when a torrent is started. It is passed as an
4780 argument to ``session::add_torrent()`` (see `add_torrent()`_).
4782 The decision to use full allocation or compact allocation typically depends on whether
4783 any files are filtered and if the filesystem supports sparse files.
4788 On filesystems that supports sparse files, this allocation mode will only use
4789 as much space as has been downloaded.
4791 * It does not require an allocation pass on startup.
4793 * It supports skipping files (setting prioirty to 0 to not download).
4795 * Fast resume data will remain valid even when file time stamps are out of date.
4801 When a torrent is started in full allocation mode, the checker thread (see threads_)
4802 will make sure that the entire storage is allocated, and fill any gaps with zeros.
4803 This will be skipped if the filesystem supports sparse files or automatic zero filling.
4804 It will of course still check for existing pieces and fast resume data. The main
4805 drawbacks of this mode are:
4807 * It may take longer to start the torrent, since it will need to fill the files
4808 with zeros on some systems. This delay is linearly dependent on the size of
4811 * The download may occupy unnecessary disk space between download sessions. In case
4812 sparse files are not supported.
4814 * Disk caches usually perform extremely poorly with random access to large files
4815 and may slow down a download considerably.
4817 The benefits of this mode are:
4819 * Downloaded pieces are written directly to their final place in the files and the
4820 total number of disk operations will be fewer and may also play nicer to
4821 filesystems' file allocation, and reduce fragmentation.
4823 * No risk of a download failing because of a full disk during download. Unless
4824 sparse files are being used.
4826 * The fast resume data will be more likely to be usable, regardless of crashes or
4827 out of date data, since pieces won't move around.
4829 * Can be used with the filter files feature.
4834 The compact allocation will only allocate as much storage as it needs to keep the
4835 pieces downloaded so far. This means that pieces will be moved around to be placed
4836 at their final position in the files while downloading (to make sure the completed
4837 download has all its pieces in the correct place). So, the main drawbacks are:
4839 * More disk operations while downloading since pieces are moved around.
4841 * Potentially more fragmentation in the filesystem.
4843 * Cannot be used while filtering files.
4845 The benefits though, are:
4847 * No startup delay, since the files doesn't need allocating.
4849 * The download will not use unnecessary disk space.
4851 * Disk caches perform much better than in full allocation and raises the download
4852 speed limit imposed by the disk.
4854 * Works well on filesystems that doesn't support sparse files.
4856 The algorithm that is used when allocating pieces and slots isn't very complicated.
4857 For the interested, a description follows.
4861 1. let **A** be a newly downloaded piece, with index **n**.
4862 2. let **s** be the number of slots allocated in the file we're
4863 downloading to. (the number of pieces it has room for).
4864 3. if **n** >= **s** then allocate a new slot and put the piece there.
4865 4. if **n** < **s** then allocate a new slot, move the data at
4866 slot **n** to the new slot and put **A** in slot **n**.
4868 allocating a new slot:
4870 1. if there's an unassigned slot (a slot that doesn't
4871 contain any piece), return that slot index.
4872 2. append the new slot at the end of the file (or find an unused slot).
4873 3. let **i** be the index of newly allocated slot
4874 4. if we have downloaded piece index **i** already (to slot **j**) then
4876 1. move the data at slot **j** to slot **i**.
4877 2. return slot index **j** as the newly allocated free slot.
4879 5. return **i** as the newly allocated slot.
4885 These extensions all operates within the `extension protocol`__. The
4886 name of the extension is the name used in the extension-list packets,
4887 and the payload is the data in the extended message (not counting the
4888 length-prefix, message-id nor extension-id).
4890 __ extension_protocol.html
4892 Note that since this protocol relies on one of the reserved bits in the
4893 handshake, it may be incompatible with future versions of the mainline
4896 These are the extensions that are currently implemented.
4901 Extension name: "LT_metadata"
4903 The point with this extension is that you don't have to distribute the
4904 metadata (.torrent-file) separately. The metadata can be distributed
4905 through the bittorrent swarm. The only thing you need to download such
4906 a torrent is the tracker url and the info-hash of the torrent.
4908 It works by assuming that the initial seeder has the metadata and that
4909 the metadata will propagate through the network as more peers join.
4911 There are three kinds of messages in the metadata extension. These packets
4912 are put as payload to the extension message. The three packets are:
4916 * don't have metadata
4920 +-----------+---------------+----------------------------------------+
4921 | size | name | description |
4922 +===========+===============+========================================+
4923 | uint8_t | msg_type | Determines the kind of message this is |
4924 | | | 0 means 'request metadata' |
4925 +-----------+---------------+----------------------------------------+
4926 | uint8_t | start | The start of the metadata block that |
4927 | | | is requested. It is given in 256:ths |
4928 | | | of the total size of the metadata, |
4929 | | | since the requesting client don't know |
4930 | | | the size of the metadata. |
4931 +-----------+---------------+----------------------------------------+
4932 | uint8_t | size | The size of the metadata block that is |
4933 | | | requested. This is also given in |
4934 | | | 256:ths of the total size of the |
4935 | | | metadata. The size is given as size-1. |
4936 | | | That means that if this field is set |
4937 | | | 0, the request wants one 256:th of the |
4939 +-----------+---------------+----------------------------------------+
4943 +-----------+---------------+----------------------------------------+
4944 | size | name | description |
4945 +===========+===============+========================================+
4946 | uint8_t | msg_type | 1 means 'metadata' |
4947 +-----------+---------------+----------------------------------------+
4948 | int32_t | total_size | The total size of the metadata, given |
4949 | | | in number of bytes. |
4950 +-----------+---------------+----------------------------------------+
4951 | int32_t | offset | The offset of where the metadata block |
4952 | | | in this message belongs in the final |
4953 | | | metadata. This is given in bytes. |
4954 +-----------+---------------+----------------------------------------+
4955 | uint8_t[] | metadata | The actual metadata block. The size of |
4956 | | | this part is given implicit by the |
4957 | | | length prefix in the bittorrent |
4958 | | | protocol packet. |
4959 +-----------+---------------+----------------------------------------+
4961 Don't have metadata:
4963 +-----------+---------------+----------------------------------------+
4964 | size | name | description |
4965 +===========+===============+========================================+
4966 | uint8_t | msg_type | 2 means 'I don't have metadata'. |
4967 | | | This message is sent as a reply to a |
4968 | | | metadata request if the the client |
4969 | | | doesn't have any metadata. |
4970 +-----------+---------------+----------------------------------------+
4975 The HTTP seed extension implements `this specification`__.
4977 The libtorrent implementation assumes that, if the URL ends with a slash
4978 ('/'), the filename should be appended to it in order to request pieces from
4979 that file. The way this works is that if the torrent is a single-file torrent,
4980 only that filename is appended. If the torrent is a multi-file torrent, the
4981 torrent's name '/' the file name is appended. This is the same directory
4982 structure that libtorrent will download torrents into.
4984 __ http://www.getright.com/seedtorrent.html
4990 Boost.Filesystem will by default check all its paths to make sure they conform
4991 to filename requirements on many platforms. If you don't want this check, you can
4992 set it to either only check for native filesystem requirements or turn it off
4993 altogether. You can use::
4995 boost::filesystem::path::default_name_check(boost::filesystem::native);
4997 for example. For more information, see the `Boost.Filesystem docs`__.
4999 __ http://www.boost.org/libs/filesystem/doc/index.htm
5005 Written by Arvid Norberg. Copyright |copy| 2003-2006
5007 Contributions by Magnus Jonsson, Daniel Wallin and Cory Nelson
5009 Lots of testing, suggestions and contributions by Massaroddel and Tianhao Qiu.
5011 Big thanks to Michael Wojciechowski and Peter Koeleman for making the autotools
5014 Thanks to Reimond Retz for bugfixes, suggestions and testing
5016 Thanks to `University of UmeƄ`__ for providing development and test hardware.
5018 Project is hosted by sourceforge.
5022 .. |copy| unicode:: 0xA9 .. copyright sign
5023 __ http://www.cs.umu.se
5024 .. |sf_logo| image:: http://sourceforge.net/sflogo.php?group_id=7994
5025 __ http://sourceforge.net