Version: 0.0.1

home

The pop_alerts() function on session is the main interface for retrieving alerts (warnings, messages and errors from libtorrent). If no alerts have been posted by libtorrent pop_alerts() will return an empty list.

By default, only errors are reported. settings_pack::alert_mask can be used to specify which kinds of events should be reported. The alert mask is a combination of the alert_category_t flags in the alert class.

Every alert belongs to one or more category. There is a cost associated with posting alerts. Only alerts that belong to an enabled category are posted. Setting the alert bitmask to 0 will disable all alerts (except those that are non-discardable). Alerts that are responses to API calls such as save_resume_data() and post_session_stats() are non-discardable and will be posted even if their category is disabled.

There are other alert base classes that some alerts derive from, all the alerts that are generated for a specific torrent are derived from torrent_alert, and tracker events derive from tracker_alert.

Alerts returned by pop_alerts() are only valid until the next call to pop_alerts(). You may not copy an alert object to access it after the next call to pop_alerts(). Internal members of alerts also become invalid once pop_alerts() is called again.

[report issue]

alert

Declared in "libtorrent/alert.hpp"

The alert class is the base class that specific messages are derived from. alert types are not copyable, and cannot be constructed by the client. The pointers returned by libtorrent are short lived (the details are described under session_handle::pop_alerts())

struct alert
{
   time_point timestamp () const;
   virtual int type () const noexcept = 0;
   virtual char const* what () const noexcept = 0;
   virtual std::string message () const = 0;
   virtual alert_category_t category () const noexcept = 0;

   static inline constexpr alert_category_t error_notification  = 0_bit;
   static inline constexpr alert_category_t peer_notification  = 1_bit;
   static inline constexpr alert_category_t port_mapping_notification  = 2_bit;
   static inline constexpr alert_category_t storage_notification  = 3_bit;
   static inline constexpr alert_category_t tracker_notification  = 4_bit;
   static inline constexpr alert_category_t connect_notification  = 5_bit;
   static inline constexpr alert_category_t status_notification  = 6_bit;
   static inline constexpr alert_category_t ip_block_notification  = 8_bit;
   static inline constexpr alert_category_t performance_warning  = 9_bit;
   static inline constexpr alert_category_t dht_notification  = 10_bit;
   static inline constexpr alert_category_t session_log_notification  = 13_bit;
   static inline constexpr alert_category_t torrent_log_notification  = 14_bit;
   static inline constexpr alert_category_t peer_log_notification  = 15_bit;
   static inline constexpr alert_category_t incoming_request_notification  = 16_bit;
   static inline constexpr alert_category_t dht_log_notification  = 17_bit;
   static inline constexpr alert_category_t dht_operation_notification  = 18_bit;
   static inline constexpr alert_category_t port_mapping_log_notification  = 19_bit;
   static inline constexpr alert_category_t picker_log_notification  = 20_bit;
   static inline constexpr alert_category_t file_progress_notification  = 21_bit;
   static inline constexpr alert_category_t piece_progress_notification  = 22_bit;
   static inline constexpr alert_category_t upload_notification  = 23_bit;
   static inline constexpr alert_category_t block_progress_notification  = 24_bit;
   static inline constexpr alert_category_t all_categories  = alert_category_t::all();
};
[report issue]

timestamp()

time_point timestamp () const;

a timestamp is automatically created in the constructor

[report issue]

type()

virtual int type () const noexcept = 0;

returns an integer that is unique to this alert type. It can be compared against a specific alert by querying a static constant called alert_type in the alert. It can be used to determine the run-time type of an alert* in order to cast to that alert type and access specific members.

e.g:

std::vector<alert*> alerts;
ses.pop_alerts(&alerts);
for (alert* a : alerts) {
        switch (a->type()) {

                case read_piece_alert::alert_type:
                {
                        auto* p = static_cast<read_piece_alert*>(a);
                        if (p->ec) {
                                // read_piece failed
                                break;
                        }
                        // use p
                        break;
                }
                case file_renamed_alert::alert_type:
                {
                        // etc...
                }
        }
}
[report issue]

what()

virtual char const* what () const noexcept = 0;

returns a string literal describing the type of the alert. It does not include any information that might be bundled with the alert.

[report issue]

message()

virtual std::string message () const = 0;

generate a string describing the alert and the information bundled with it. This is mainly intended for debug and development use. It is not suitable to use this for applications that may be localized. Instead, handle each alert type individually and extract and render the information from the alert depending on the locale.

[report issue]

category()

virtual alert_category_t category () const noexcept = 0;

returns a bitmask specifying which categories this alert belong to.

[report issue]

dht_routing_bucket

Declared in "libtorrent/alert_types.hpp"

struct to hold information about a single DHT routing table bucket

struct dht_routing_bucket
{
   int num_nodes;
   int num_replacements;
   int last_active;
};
[report issue]
num_nodes num_replacements
the total number of nodes and replacement nodes in the routing table
[report issue]
last_active
number of seconds since last activity
[report issue]

torrent_alert

Declared in "libtorrent/alert_types.hpp"

This is a base class for alerts that are associated with a specific torrent. It contains a handle to the torrent.

Note that by the time the client receives a torrent_alert, its handle member may be invalid.

struct torrent_alert : alert
{
   std::string message () const override;
   char const* torrent_name () const;

   torrent_handle handle;
};
[report issue]

message()

std::string message () const override;

returns the message associated with this alert

[report issue]
handle
The torrent_handle pointing to the torrent this alert is associated with.
[report issue]

peer_alert

Declared in "libtorrent/alert_types.hpp"

The peer alert is a base class for alerts that refer to a specific peer. It includes all the information to identify the peer. i.e. ip and peer-id.

struct peer_alert : torrent_alert
{
   std::string message () const override;

   aux::noexcept_movable<tcp::endpoint> endpoint;
   peer_id pid;
};
[report issue]
endpoint
The peer's IP address and port.
[report issue]
pid
the peer ID, if known.
[report issue]

udp_error_alert

Declared in "libtorrent/alert_types.hpp"

This alert is posted when there is an error on a UDP socket. The UDP sockets are used for all uTP, DHT and UDP tracker traffic. They are global to the session.

struct udp_error_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::error;
   aux::noexcept_movable<udp::endpoint> endpoint;
   operation_t operation;
   error_code const error;
};
[report issue]
endpoint
the source address associated with the error (if any)
[report issue]
operation
the operation that failed
[report issue]
error
the error code describing the error
[report issue]

external_ip_alert

Declared in "libtorrent/alert_types.hpp"

Whenever libtorrent learns about the machines external IP, this alert is generated. The external IP address can be acquired from the tracker (if it supports that) or from peers that supports the extension protocol. The address can be accessed through the external_address member.

struct external_ip_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::status;
   aux::noexcept_movable<address> external_address;
};
[report issue]
external_address
the IP address that is believed to be our external IP
[report issue]

listen_failed_alert

Declared in "libtorrent/alert_types.hpp"

This alert is generated when none of the ports, given in the port range, to session can be opened for listening. The listen_interface member is the interface that failed, error is the error code describing the failure.

In the case an endpoint was created before generating the alert, it is represented by address and port. The combinations of socket type and operation in which such address and port are not valid are: accept - i2p accept - socks5 enum_if - tcp

libtorrent may sometimes try to listen on port 0, if all other ports failed. Port 0 asks the operating system to pick a port that's free). If that fails you may see a listen_failed_alert with port 0 even if you didn't ask to listen on it.

struct listen_failed_alert final : alert
{
   std::string message () const override;
   char const* listen_interface () const;

   static inline constexpr alert_category_t static_category  = alert_category::status | alert_category::error;
   error_code const error;
   operation_t op;
   lt::socket_type_t const socket_type;
   aux::noexcept_movable<lt::address> address;
   int const port;
};
[report issue]

listen_interface()

char const* listen_interface () const;

the network device libtorrent attempted to listen on, or the IP address

[report issue]
error
the error the system returned
[report issue]
op
the underlying operation that failed
[report issue]
socket_type
the type of listen socket this alert refers to.
[report issue]
address
the address libtorrent attempted to listen on see alert documentation for validity of this value
[report issue]
port
the port libtorrent attempted to listen on see alert documentation for validity of this value
[report issue]

listen_succeeded_alert

Declared in "libtorrent/alert_types.hpp"

This alert is posted when the listen port succeeds to be opened on a particular interface. address and port is the endpoint that successfully was opened for listening.

struct listen_succeeded_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::status;
   aux::noexcept_movable<lt::address> address;
   int const port;
   lt::socket_type_t const socket_type;
};
[report issue]
address
the address libtorrent ended up listening on. This address refers to the local interface.
[report issue]
port
the port libtorrent ended up listening on.
[report issue]
socket_type
the type of listen socket this alert refers to.
[report issue]

portmap_error_alert

Declared in "libtorrent/alert_types.hpp"

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

struct portmap_error_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::port_mapping
   | alert_category::error;
   port_mapping_t const mapping;
   portmap_transport map_transport;
   aux::noexcept_movable<address> local_address;
   error_code const error;
};
[report issue]
mapping
refers to the mapping index of the port map that failed, i.e. the index returned from add_mapping().
[report issue]
map_transport
UPnP or NAT-PMP
[report issue]
local_address
the local network the port mapper is running on
[report issue]
error
tells you what failed.
[report issue]

portmap_alert

Declared in "libtorrent/alert_types.hpp"

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

struct portmap_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::port_mapping;
   port_mapping_t const mapping;
   int const external_port;
   portmap_protocol const map_protocol;
   portmap_transport const map_transport;
   aux::noexcept_movable<address> local_address;
};
[report issue]
mapping
refers to the mapping index of the port map that failed, i.e. the index returned from add_mapping().
[report issue]
external_port
the external port allocated for the mapping.
[report issue]
local_address
the local network the port mapper is running on
[report issue]

portmap_log_alert

Declared in "libtorrent/alert_types.hpp"

This alert is generated to log informational events related to either UPnP or NAT-PMP. They contain a log line and the type (0 = NAT-PMP and 1 = UPnP). Displaying these messages to an end user is only useful for debugging the UPnP or NAT-PMP implementation. This alert is only posted if the alert_category::port_mapping_log flag is enabled in the alert mask.

struct portmap_log_alert final : alert
{
   std::string message () const override;
   char const* log_message () const;

   static inline constexpr alert_category_t static_category  = alert_category::port_mapping_log;
   portmap_transport const map_transport;
   aux::noexcept_movable<address> local_address;
};
[report issue]

log_message()

char const* log_message () const;

the message associated with this log line

[report issue]
local_address
the local network the port mapper is running on
[report issue]

dht_announce_alert

Declared in "libtorrent/alert_types.hpp"

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

struct dht_announce_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
   aux::noexcept_movable<address> ip;
   int port;
   sha256_hash info_hash;
};
[report issue]

dht_get_peers_alert

Declared in "libtorrent/alert_types.hpp"

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

struct dht_get_peers_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
   sha256_hash info_hash;
};
[report issue]

dht_bootstrap_alert

Declared in "libtorrent/alert_types.hpp"

This alert is posted when the initial DHT bootstrap is done.

struct dht_bootstrap_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
};
[report issue]

torrent_error_alert

Declared in "libtorrent/alert_types.hpp"

This is posted whenever a torrent is transitioned into the error state.

struct torrent_error_alert final : torrent_alert
{
   std::string message () const override;
   char const* filename () const;

   static inline constexpr alert_category_t static_category  = alert_category::error | alert_category::status;
   error_code const error;
};
[report issue]

filename()

char const* filename () const;

the filename (or object) the error occurred on.

[report issue]
error
specifies which error the torrent encountered.
[report issue]

incoming_connection_alert

Declared in "libtorrent/alert_types.hpp"

The incoming connection alert is posted every time we successfully accept an incoming connection, through any mean. The most straight-forward ways of accepting incoming connections are through the TCP listen socket and the UDP listen socket for uTP sockets. However, connections may also be accepted through a Socks5 or i2p listen socket, or via an SSL listen socket.

struct incoming_connection_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::peer;
   socket_type_t socket_type;
   aux::noexcept_movable<tcp::endpoint> endpoint;
};
[report issue]
socket_type
tells you what kind of socket the connection was accepted
[report issue]
endpoint
is the IP address and port the connection came from.
[report issue]

state_update_alert

Declared in "libtorrent/alert_types.hpp"

This alert is only posted when requested by the user, by calling session::post_torrent_updates() on the session. It contains the torrent status of all torrents that changed since last time this message was posted. Its category is alert_category::status, but it's not subject to filtering, since it's only manually posted anyway.

struct state_update_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::status;
   std::vector<torrent_status> status;
};
[report issue]
status
contains the torrent status of all torrents that changed since last time this message was posted. Note that you can map a torrent status to a specific torrent via its handle member. The receiving end is suggested to have all torrents sorted by the torrent_handle or hashed by it, for efficient updates.
[report issue]

session_stats_alert

Declared in "libtorrent/alert_types.hpp"

The session_stats_alert is posted when the user requests session statistics by calling post_session_stats() on the session object. This alert does not have a category, since it's only posted in response to an API call. It is not subject to the alert_mask filter.

the message() member function returns a string representation of the values that properly match the line returned in session_stats_header_alert::message().

this specific output is parsed by tools/parse_session_stats.py if this is changed, that parser should also be changed

struct session_stats_alert final : alert
{
   std::string message () const override;
   span<std::int64_t const> counters () const;

   static inline constexpr alert_category_t static_category  = {};
};
[report issue]

counters()

span<std::int64_t const> counters () const;

An array are a mix of counters and gauges, which meanings can be queries via the session_stats_metrics() function on the session. The mapping from a specific metric to an index into this array is constant for a specific version of libtorrent, but may differ for other versions. The intended usage is to request the mapping, i.e. call session_stats_metrics(), once on startup, and then use that mapping to interpret these values throughout the process' runtime.

For more information, see the session statistics section.

[report issue]

dht_error_alert

Declared in "libtorrent/alert_types.hpp"

posted when something fails in the DHT. This is not necessarily a fatal error, but it could prevent proper operation

struct dht_error_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::error | alert_category::dht;
   error_code error;
   operation_t op;
};
[report issue]
error
the error code
[report issue]
op
the operation that failed
[report issue]

dht_immutable_item_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted as a response to a call to session::get_item(), specifically the overload for looking up immutable items in the DHT.

struct dht_immutable_item_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
   sha256_hash target;
   entry item;
};
[report issue]
target
the target hash of the immutable item. This must match the SHA-2 hash of the bencoded form of item.
[report issue]
item
the data for this item
[report issue]

dht_mutable_item_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted as a response to a call to session::get_item(), specifically the overload for looking up mutable items in the DHT.

struct dht_mutable_item_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
   std::array<char, 32> key;
   std::array<char, 64> signature;
   std::int64_t seq;
   std::string salt;
   entry item;
   bool authoritative;
};
[report issue]
key
the public key that was looked up
[report issue]
signature
the signature of the data. This is not the signature of the plain encoded form of the item, but it includes the sequence number and possibly the hash as well. See the dht_store document for more information. This is primarily useful for echoing back in a store request.
[report issue]
seq
the sequence number of this item
[report issue]
salt
the salt, if any, used to lookup and store this item. If no salt was used, this is an empty string
[report issue]
item
the data for this item
[report issue]
authoritative
the last response for mutable data is authoritative.
[report issue]

dht_put_alert

Declared in "libtorrent/alert_types.hpp"

this is posted when a DHT put operation completes. This is useful if the client is waiting for a put to complete before shutting down for instance.

struct dht_put_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
   sha256_hash target;
   std::array<char, 32> public_key;
   std::array<char, 64> signature;
   std::string salt;
   std::int64_t seq;
   int num_success;
};
[report issue]
target
the target hash the item was stored under if this was an immutable item.
[report issue]
public_key signature salt seq
if a mutable item was stored, these are the public key, signature, salt and sequence number the item was stored under.
[report issue]
num_success
DHT put operation usually writes item to k nodes, maybe the node is stale so no response, or the node doesn't support 'put', or the token for write is out of date, etc. num_success is the number of successful responses we got from the puts.
[report issue]

dht_outgoing_get_peers_alert

Declared in "libtorrent/alert_types.hpp"

This alert is generated when we send a get_peers request It belongs to the alert_category::dht category.

struct dht_outgoing_get_peers_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
   sha256_hash info_hash;
   sha256_hash obfuscated_info_hash;
   aux::noexcept_movable<udp::endpoint> endpoint;
};
[report issue]
info_hash
the info_hash of the torrent we're looking for peers for.
[report issue]
obfuscated_info_hash
if this was an obfuscated lookup, this is the info-hash target actually sent to the node.
[report issue]
endpoint
the endpoint we're sending this query to
[report issue]

log_alert

Declared in "libtorrent/alert_types.hpp"

This alert is posted by some session wide event. Its main purpose is trouble shooting and debugging. It's not enabled by the default alert mask and is enabled by the alert_category::session_log bit. Furthermore, it's by default disabled as a build configuration.

struct log_alert final : alert
{
   std::string message () const override;
   char const* log_message () const;

   static inline constexpr alert_category_t static_category  = alert_category::session_log;
};
[report issue]

log_message()

char const* log_message () const;

returns the log message

[report issue]

peer_log_alert

Declared in "libtorrent/alert_types.hpp"

This alert is posted by events specific to a peer. It's meant to be used for trouble shooting and debugging. It's not enabled by the default alert mask and is enabled by the alert_category::peer_log bit. By default it is disabled as a build configuration.

struct peer_log_alert final : peer_alert
{
   std::string message () const override;
   char const* log_message () const;

   enum direction_t
   {
      incoming_message,
      outgoing_message,
      incoming,
      outgoing,
      info,
   };

   static inline constexpr alert_category_t static_category  = alert_category::peer_log;
   char const* event_type;
   direction_t direction;
};
[report issue]

log_message()

char const* log_message () const;

returns the log message

[report issue]

enum direction_t

Declared in "libtorrent/alert_types.hpp"

name value description
incoming_message 0  
outgoing_message 1  
incoming 2  
outgoing 3  
info 4  
[report issue]
event_type
string literal indicating the kind of event. For messages, this is the message name.
[report issue]

dht_lookup

Declared in "libtorrent/alert_types.hpp"

holds statistics about a current dht_lookup operation. a DHT lookup is the traversal of nodes, looking up a set of target nodes in the DHT for retrieving and possibly storing information in the DHT

struct dht_lookup
{
   char const* type;
   int outstanding_requests;
   int timeouts;
   int responses;
   int branch_factor;
   int nodes_left;
   int last_sent;
   int first_timeout;
   sha1_hash target;
};
[report issue]
type
string literal indicating which kind of lookup this is
[report issue]
outstanding_requests
the number of outstanding request to individual nodes this lookup has right now
[report issue]
timeouts
the total number of requests that have timed out so far for this lookup
[report issue]
responses
the total number of responses we have received for this lookup so far for this lookup
[report issue]
branch_factor
the branch factor for this lookup. This is the number of nodes we keep outstanding requests to in parallel by default. when nodes time out we may increase this.
[report issue]
nodes_left
the number of nodes left that could be queries for this lookup. Many of these are likely to be part of the trail while performing the lookup and would never end up actually being queried.
[report issue]
last_sent
the number of seconds ago the last message was sent that's still outstanding
[report issue]
first_timeout
the number of outstanding requests that have exceeded the short timeout and are considered timed out in the sense that they increased the branch factor
[report issue]
target
the node-id or info-hash target for this lookup
[report issue]

dht_stats_alert

Declared in "libtorrent/alert_types.hpp"

contains current DHT state. Posted in response to session::post_dht_stats().

struct dht_stats_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = {};
   std::vector<dht_lookup> active_requests;
   std::vector<dht_routing_bucket> routing_table;
   sha256_hash nid;
   aux::noexcept_movable<udp::endpoint> local_endpoint;
};
[report issue]
active_requests
a vector of the currently running DHT lookups.
[report issue]
routing_table
contains information about every bucket in the DHT routing table.
[report issue]
nid
the node ID of the DHT node instance
[report issue]
local_endpoint
the local socket this DHT node is running on
[report issue]

dht_log_alert

Declared in "libtorrent/alert_types.hpp"

debug logging of the DHT when alert_category::dht_log is set in the alert mask.

struct dht_log_alert final : alert
{
   std::string message () const override;
   char const* log_message () const;

   enum dht_module_t
   {
      tracker,
      node,
      routing_table,
      rpc_manager,
      traversal,
   };

   static inline constexpr alert_category_t static_category  = alert_category::dht_log;
   dht_module_t module;
};
[report issue]

log_message()

char const* log_message () const;

the log message

[report issue]

enum dht_module_t

Declared in "libtorrent/alert_types.hpp"

name value description
tracker 0  
node 1  
routing_table 2  
rpc_manager 3  
traversal 4  
[report issue]
module
the module, or part, of the DHT that produced this log message.
[report issue]

dht_pkt_alert

Declared in "libtorrent/alert_types.hpp"

This alert is posted every time a DHT message is sent or received. It is only posted if the alert_category::dht_log alert category is enabled. It contains a verbatim copy of the message.

struct dht_pkt_alert final : alert
{
   std::string message () const override;
   span<char const> pkt_buf () const;

   enum direction_t
   {
      incoming,
      outgoing,
   };

   static inline constexpr alert_category_t static_category  = alert_category::dht_log;
   direction_t direction;
   aux::noexcept_movable<udp::endpoint> node;
};
[report issue]

pkt_buf()

span<char const> pkt_buf () const;

returns a pointer to the packet buffer and size of the packet, respectively. This buffer is only valid for as long as the alert itself is valid, which is owned by libtorrent and reclaimed whenever pop_alerts() is called on the session.

[report issue]

enum direction_t

Declared in "libtorrent/alert_types.hpp"

name value description
incoming 0  
outgoing 1  
[report issue]
direction
whether this is an incoming or outgoing packet.
[report issue]
node
the DHT node we received this packet from, or sent this packet to (depending on direction).
[report issue]

dht_get_peers_reply_alert

Declared in "libtorrent/alert_types.hpp"

Posted when we receive a response to a DHT get_peers request.

struct dht_get_peers_reply_alert final : alert
{
   std::string message () const override;
   int num_peers () const;
   std::vector<tcp::endpoint> peers () const;

   static inline constexpr alert_category_t static_category  = alert_category::dht_operation;
   sha1_hash info_hash;
};
[report issue]

dht_direct_response_alert

Declared in "libtorrent/alert_types.hpp"

This is posted exactly once for every call to session_handle::dht_direct_request. If the request failed, response() will return a default constructed bdecode_node.

struct dht_direct_response_alert final : alert
{
   std::string message () const override;
   bdecode_node response () const;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
   client_data_t userdata;
   aux::noexcept_movable<udp::endpoint> endpoint;
};
[report issue]

picker_log_alert

Declared in "libtorrent/alert_types.hpp"

this is posted when one or more blocks are picked by the piece picker, assuming the verbose piece picker logging is enabled (see alert_category::picker_log).

struct picker_log_alert final : peer_alert
{
   std::string message () const override;
   std::vector<piece_block> blocks () const;

   static inline constexpr alert_category_t static_category  = alert_category::picker_log;
   static inline constexpr picker_flags_t partial_ratio  = 0_bit;
   static inline constexpr picker_flags_t prioritize_partials  = 1_bit;
   static inline constexpr picker_flags_t rarest_first_partials  = 2_bit;
   static inline constexpr picker_flags_t rarest_first  = 3_bit;
   static inline constexpr picker_flags_t reverse_rarest_first  = 4_bit;
   static inline constexpr picker_flags_t suggested_pieces  = 5_bit;
   static inline constexpr picker_flags_t prio_sequential_pieces  = 6_bit;
   static inline constexpr picker_flags_t sequential_pieces  = 7_bit;
   static inline constexpr picker_flags_t reverse_pieces  = 8_bit;
   static inline constexpr picker_flags_t time_critical  = 9_bit;
   static inline constexpr picker_flags_t random_pieces  = 10_bit;
   static inline constexpr picker_flags_t prefer_contiguous  = 11_bit;
   static inline constexpr picker_flags_t reverse_sequential  = 12_bit;
   static inline constexpr picker_flags_t backup1  = 13_bit;
   static inline constexpr picker_flags_t backup2  = 14_bit;
   static inline constexpr picker_flags_t end_game  = 15_bit;
   static inline constexpr picker_flags_t extent_affinity  = 16_bit;
   picker_flags_t picker_flags;
};
[report issue]
picker_flags
this is a bitmask of which features were enabled for this particular pick. The bits are defined in the picker_flags_t enum.
[report issue]

session_error_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted when the session encounters a serious error, potentially fatal

struct session_error_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::error;
   error_code const error;
};
[report issue]
error
The error code, if one is associated with this error
[report issue]

dht_live_nodes_alert

Declared in "libtorrent/alert_types.hpp"

posted in response to a call to session::dht_live_nodes(). It contains the live nodes from the DHT routing table of one of the DHT nodes running locally.

struct dht_live_nodes_alert final : alert
{
   std::string message () const override;
   std::vector<std::pair<sha256_hash, udp::endpoint>> nodes () const;
   int num_nodes () const;

   static inline constexpr alert_category_t static_category  = alert_category::dht;
   sha256_hash node_id;
};
[report issue]

num_nodes() nodes()

std::vector<std::pair<sha256_hash, udp::endpoint>> nodes () const;
int num_nodes () const;

the number of nodes in the routing table and the actual nodes.

[report issue]
node_id
the local DHT node's node-ID this routing table belongs to
[report issue]

session_stats_header_alert

Declared in "libtorrent/alert_types.hpp"

The session_stats_header alert is posted the first time post_session_stats() is called

the message() member function returns a string representation of the header that properly match the stats values string returned in session_stats_alert::message().

this specific output is parsed by tools/parse_session_stats.py if this is changed, that parser should also be changed

struct session_stats_header_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = {};
};
[report issue]

dht_sample_infohashes_alert

Declared in "libtorrent/alert_types.hpp"

posted as a response to a call to session::dht_sample_infohashes() with the information from the DHT response message.

struct dht_sample_infohashes_alert final : alert
{
   std::string message () const override;
   std::vector<sha256_hash> samples () const;
   int num_samples () const;
   int num_nodes () const;
   std::vector<std::pair<sha256_hash, udp::endpoint>> nodes () const;

   static inline constexpr alert_category_t static_category  = alert_category::dht_operation;
   sha256_hash node_id;
   aux::noexcept_movable<udp::endpoint> endpoint;
   time_duration const interval;
   int const num_infohashes;
};
[report issue]

samples() num_samples()

std::vector<sha256_hash> samples () const;
int num_samples () const;

returns the number of info-hashes returned by the node, as well as the actual info-hashes. num_samples() is more efficient than samples().size().

[report issue]

num_nodes()

int num_nodes () const;

The total number of nodes returned by nodes().

[report issue]

nodes()

std::vector<std::pair<sha256_hash, udp::endpoint>> nodes () const;

This is the set of more DHT nodes returned by the request.

The information is included so that indexing nodes can perform a key space traversal with a single RPC per node by adjusting the target value for each RPC.

[report issue]
node_id
id of the node the request was sent to (and this response was received from)
[report issue]
endpoint
the node the request was sent to (and this response was received from)
[report issue]
interval
the interval to wait before making another request to this node
[report issue]
num_infohashes
This field indicates how many info-hash keys are currently in the node's storage. If the value is larger than the number of returned samples it indicates that the indexer may obtain additional samples after waiting out the interval.
[report issue]

alerts_dropped_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted to indicate to the client that some alerts were dropped. Dropped meaning that the alert failed to be delivered to the client. The most common cause of such failure is that the internal alert queue grew too big (controlled by alert_queue_size).

struct alerts_dropped_alert final : alert
{
   static_assert (num_alert_types <= abi_alert_count, "need to increase bitset. This is an ABI break");
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::error;
   std::bitset<abi_alert_count> dropped_alerts;
};
[report issue]
dropped_alerts
a bitmask indicating which alerts were dropped. Each bit represents the alert type ID, where bit 0 represents whether any alert of type 0 has been dropped, and so on.
[report issue]

socks5_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted with SOCKS5 related errors, when a SOCKS5 proxy is configured. It's enabled with the alert_category::error alert category.

struct socks5_alert final : alert
{
   std::string message () const override;

   static inline constexpr alert_category_t static_category  = alert_category::error;
   error_code error;
   operation_t op;
   aux::noexcept_movable<tcp::endpoint> ip;
};
[report issue]
error
the error
[report issue]
op
the operation that failed
[report issue]
ip
the endpoint configured as the proxy
[report issue]

communication_new_device_id_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted when new device id is found on net.

struct communication_new_device_id_alert final : alert
{
   std::string message () const override;

   static constexpr alert_category_t static_category  = alert_category::communication;
   aux::bytesConstRef device_id;
};
[report issue]
device_id
device id found
[report issue]

communication_new_message_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted when new message is found from other peers.

struct communication_new_message_alert final : alert
{
   std::string message () const override;

   static constexpr alert_category_t static_category  = alert_category::communication;
   communication::message msg;
};
[report issue]
msg
message found from peers.
[report issue]

communication_confirmation_root_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted when message hash is confirmed by peers.

struct communication_confirmation_root_alert final : alert
{
   std::string message () const override;

   static constexpr alert_category_t static_category  = alert_category::communication;
   aux::bytesConstRef confirmation_root;
};
[report issue]
confirmation_root
confirmation root
[report issue]

communication_syncing_message_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted when a message is syncing.

struct communication_syncing_message_alert final : alert
{
   std::string message () const override;

   static constexpr alert_category_t static_category  = alert_category::communication;
   aux::bytesConstRef syncing_msg_hash;
};
[report issue]
syncing_msg_hash
syncing message hash
[report issue]

communication_friend_info_alert

Declared in "libtorrent/alert_types.hpp"

this alert is posted when friend info found in new mutable data.

struct communication_friend_info_alert final : alert
{
   std::string message () const override;

   static constexpr alert_category_t static_category  = alert_category::communication;
   aux::bytes friend_info;
};
[report issue]
friend_info
friend info
[report issue]

alert_cast()

Declared in "libtorrent/alert.hpp"

template <typename T> T* alert_cast (alert* a);
template <typename T> T const* alert_cast (alert const* a);

When you get an alert, you can use alert_cast<> to attempt to cast the pointer to a specific alert type, in order to query it for more information.

Note

alert_cast<> can only cast to an exact alert type, not a base class

[report issue]

alert_category_t

Declared in "libtorrent/alert.hpp"

error

Enables alerts that report an error. This includes:

  • tracker errors
  • tracker warnings
  • file errors
  • resume data failures
  • web seed errors
  • .torrent files errors
  • listen socket errors
  • port mapping errors
peer
Enables alerts when peers send invalid requests, get banned or snubbed.
port_mapping
Enables alerts for port mapping events. For NAT-PMP and UPnP.
storage
Enables alerts for events related to the storage. File errors and synchronization events for moving the storage, renaming files etc.
tracker
Enables all tracker events. Includes announcing to trackers, receiving responses, warnings and errors.
connect
Low level alerts for when peers are connected and disconnected.
status
Enables alerts for when a torrent or the session changes state.
ip_block
Alerts when a peer is blocked by the ip blocker or port blocker.
performance_warning
Alerts when some limit is reached that might limit the download or upload rate.
dht
Alerts on events in the DHT node. For incoming searches or bootstrapping being done etc.
stats
If you enable these alerts, you will receive a stats_alert approximately once every second, for every active torrent. These alerts contain all statistics counters for the interval since the lasts stats alert.
session_log
Enables debug logging alerts. These are available unless libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The alerts being posted are log_alert and are session wide.
torrent_log
Enables debug logging alerts for torrents. These are available unless libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The alerts being posted are torrent_log_alert and are torrent wide debug events.
peer_log
Enables debug logging alerts for peers. These are available unless libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The alerts being posted are peer_log_alert and low-level peer events and messages.
incoming_request
enables the incoming_request_alert.
dht_log
enables dht_log_alert, debug logging for the DHT
dht_operation
enable events from pure dht operations not related to torrents
port_mapping_log
enables port mapping log events. This log is useful for debugging the UPnP or NAT-PMP implementation
picker_log
enables verbose logging from the piece picker.
file_progress
alerts when files complete downloading
piece_progress
alerts when pieces complete downloading or fail hash check
upload
alerts when we upload blocks to other peers
block_progress
alerts on individual blocks being requested, downloading, finished, rejected, time-out and cancelled. This is likely to post alerts at a high rate.
communication
alerts on events in communication
all

The full bitmask, representing all available categories.

since the enum is signed, make sure this isn't interpreted as -1. For instance, boost.python does that and fails when assigning it to an unsigned parameter.

[report issue]

int

Declared in "libtorrent/alert_types.hpp"

user_alert_id
user defined alerts should use IDs greater than this
num_alert_types
this constant represents "max_alert_index" + 1