libtorrent::bt_peer_connection Class Reference

#include <bt_peer_connection.hpp>

Inheritance diagram for libtorrent::bt_peer_connection:

libtorrent::peer_connection

List of all members.

Public Types

enum  message_type {
  msg_choke = 0, msg_unchoke, msg_interested, msg_not_interested,
  msg_have, msg_bitfield, msg_request, msg_piece,
  msg_cancel, msg_dht_port, msg_extended = 20, num_supported_messages
}
typedef void(bt_peer_connection::* message_handler )(int received)

Public Member Functions

 bt_peer_connection (aux::session_impl &ses, boost::weak_ptr< torrent > t, boost::shared_ptr< stream_socket > s, tcp::endpoint const &remote)
 bt_peer_connection (aux::session_impl &ses, boost::shared_ptr< stream_socket > s)
 ~bt_peer_connection ()
void on_sent (asio::error_code const &error, std::size_t bytes_transferred)
void on_receive (asio::error_code const &error, std::size_t bytes_transferred)
virtual void get_peer_info (peer_info &p) const
virtual bool in_handshake () const
bool support_extensions () const
template<class T>
T * supports_extension () const
void on_keepalive ()
void on_choke (int received)
void on_unchoke (int received)
void on_interested (int received)
void on_not_interested (int received)
void on_have (int received)
void on_bitfield (int received)
void on_request (int received)
void on_piece (int received)
void on_cancel (int received)
void on_dht_port (int received)
void on_extended (int received)
void on_extended_handshake ()
void write_choke ()
void write_unchoke ()
void write_interested ()
void write_not_interested ()
void write_request (peer_request const &r)
void write_cancel (peer_request const &r)
void write_bitfield (std::vector< bool > const &bitfield)
void write_have (int index)
void write_piece (peer_request const &r)
void write_handshake ()
void write_extensions ()
void write_chat_message (const std::string &msg)
void write_metadata (std::pair< int, int > req)
void write_metadata_request (std::pair< int, int > req)
void write_keepalive ()
void write_dht_port (int listen_port)
void on_connected ()
void on_metadata ()
void check_invariant () const

Public Attributes

boost::posix_time::ptime m_last_choke

Private Types

enum  state {
  read_protocol_length = 0, read_protocol_string, read_info_hash, read_peer_id,
  read_packet_size, read_packet
}

Private Member Functions

bool dispatch_message (int received)
boost::optional
< piece_block_progress
downloading_piece_progress () const

Static Private Member Functions

static bool range_below_zero (const range &r)

Private Attributes

std::string m_client_version
state m_state
int m_timeout
std::deque< rangem_payloads
bool m_supports_extensions
bool m_supports_dht_port
bool m_sent_bitfield
bool m_in_constructor

Static Private Attributes

static const message_handler m_message_handler [num_supported_messages]

Friends

class invariant_access

Classes

struct  range


Detailed Description

Definition at line 82 of file bt_peer_connection.hpp.


Member Typedef Documentation

typedef void(bt_peer_connection::* libtorrent::bt_peer_connection::message_handler)(int received)


Member Enumeration Documentation

Enumerator:
msg_choke 
msg_unchoke 
msg_interested 
msg_not_interested 
msg_have 
msg_bitfield 
msg_request 
msg_piece 
msg_cancel 
msg_dht_port 
msg_extended 
num_supported_messages 

Definition at line 105 of file bt_peer_connection.hpp.

Enumerator:
read_protocol_length 
read_protocol_string 
read_info_hash 
read_peer_id 
read_packet_size 
read_packet 

Definition at line 215 of file bt_peer_connection.hpp.


Constructor & Destructor Documentation

libtorrent::bt_peer_connection::bt_peer_connection ( aux::session_impl ses,
boost::weak_ptr< torrent t,
boost::shared_ptr< stream_socket s,
tcp::endpoint const &  remote 
)

libtorrent::bt_peer_connection::bt_peer_connection ( aux::session_impl ses,
boost::shared_ptr< stream_socket s 
)

libtorrent::bt_peer_connection::~bt_peer_connection (  ) 

Definition at line 125 of file bt_peer_connection.cpp.


Member Function Documentation

void libtorrent::bt_peer_connection::on_sent ( asio::error_code const &  error,
std::size_t  bytes_transferred 
) [virtual]

void libtorrent::bt_peer_connection::on_receive ( asio::error_code const &  error,
std::size_t  bytes_transferred 
) [virtual]

Implements libtorrent::peer_connection.

Definition at line 1057 of file bt_peer_connection.cpp.

References libtorrent::peer_connection::associated_torrent(), libtorrent::peer_connection::attach_to_torrent(), libtorrent::big_number::begin(), libtorrent::buffer::const_interval::begin, libtorrent::policy::begin_peer(), asio::buffer(), libtorrent::client_fingerprint(), dispatch_message(), libtorrent::big_number::end(), libtorrent::buffer::const_interval::end, libtorrent::policy::end_peer(), libtorrent::aux::session_impl::get_peer_id(), libtorrent::peer_connection::get_socket(), libtorrent::identify_client(), libtorrent::peer_connection::incoming_keepalive(), INVARIANT_CHECK, libtorrent::peer_connection::is_local(), asio::placeholders::iterator, libtorrent::aux::session_impl::kad_settings(), LIBTORRENT_VERSION, m_client_version, libtorrent::aux::session_impl::m_dht, libtorrent::peer_connection::m_extensions, libtorrent::peer_connection::m_max_out_request_queue, libtorrent::peer_connection::m_ses, m_state, libtorrent::peer_connection::m_statistics, m_supports_dht_port, m_supports_extensions, libtorrent::peer_connection::packet_finished(), libtorrent::peer_connection::packet_size(), libtorrent::peer_connection::pid(), read_info_hash, libtorrent::detail::read_int32(), read_packet, read_packet_size, read_peer_id, read_protocol_length, read_protocol_string, libtorrent::peer_connection::receive_buffer(), libtorrent::stat::received_bytes(), libtorrent::peer_connection::reset_recv_buffer(), libtorrent::dht_settings::service_port, libtorrent::peer_connection::set_pid(), asio::write(), write_bitfield(), write_dht_port(), write_extensions(), and write_handshake().

void libtorrent::bt_peer_connection::get_peer_info ( peer_info p  )  const [virtual]

Implements libtorrent::peer_connection.

Definition at line 148 of file bt_peer_connection.cpp.

References libtorrent::peer_connection::associated_torrent(), libtorrent::peer_info::choked, libtorrent::peer_info::client, libtorrent::peer_info::connecting, libtorrent::peer_info::connection_type, libtorrent::peer_info::country, libtorrent::peer_info::down_speed, libtorrent::peer_connection::download_channel, libtorrent::peer_info::download_limit, libtorrent::stat::download_payload_rate(), libtorrent::peer_connection::download_queue(), libtorrent::peer_info::download_queue_length, libtorrent::stat::download_rate(), libtorrent::peer_info::downloading_block_index, libtorrent::peer_info::downloading_piece_index, downloading_piece_progress(), libtorrent::peer_info::downloading_progress, libtorrent::peer_info::downloading_total, libtorrent::peer_info::flags, libtorrent::peer_connection::get_bitfield(), libtorrent::peer_info::handshake, libtorrent::peer_connection::has_peer_choked(), libtorrent::bandwidth_limit::inf, libtorrent::peer_info::interesting, libtorrent::peer_info::ip, libtorrent::peer_connection::is_choked(), libtorrent::peer_connection::is_connecting(), libtorrent::peer_connection::is_interesting(), libtorrent::peer_connection::is_local(), libtorrent::peer_connection::is_peer_interested(), libtorrent::peer_connection::is_queued(), libtorrent::peer_connection::is_seed(), libtorrent::peer_info::load_balancing, libtorrent::peer_info::local_connection, libtorrent::peer_connection::m_bandwidth_limit, m_client_version, libtorrent::peer_connection::m_country, m_state, libtorrent::peer_info::payload_down_speed, libtorrent::peer_info::payload_up_speed, libtorrent::peer_connection::pid(), libtorrent::peer_info::pid, libtorrent::peer_info::pieces, libtorrent::peer_info::queued, read_packet_size, libtorrent::peer_connection::remote(), libtorrent::peer_info::remote_choked, libtorrent::peer_info::remote_interested, libtorrent::peer_info::seed, libtorrent::peer_info::standard_bittorrent, libtorrent::peer_connection::statistics(), support_extensions(), libtorrent::peer_info::supports_extensions, libtorrent::bandwidth_limit::throttle(), libtorrent::peer_info::total_download, libtorrent::peer_connection::total_free_upload(), libtorrent::stat::total_payload_download(), libtorrent::stat::total_payload_upload(), libtorrent::peer_info::total_upload, libtorrent::peer_info::up_speed, libtorrent::peer_connection::upload_channel, libtorrent::peer_info::upload_limit, libtorrent::stat::upload_payload_rate(), libtorrent::peer_connection::upload_queue(), libtorrent::peer_info::upload_queue_length, and libtorrent::stat::upload_rate().

bool libtorrent::bt_peer_connection::in_handshake (  )  const [virtual]

Implements libtorrent::peer_connection.

Definition at line 214 of file bt_peer_connection.cpp.

References m_state, and read_packet_size.

bool libtorrent::bt_peer_connection::support_extensions (  )  const [inline]

Definition at line 136 of file bt_peer_connection.hpp.

Referenced by get_peer_info().

template<class T>
T* libtorrent::bt_peer_connection::supports_extension (  )  const [inline]

Definition at line 139 of file bt_peer_connection.hpp.

void libtorrent::bt_peer_connection::on_keepalive (  ) 

void libtorrent::bt_peer_connection::on_choke ( int  received  ) 

void libtorrent::bt_peer_connection::on_unchoke ( int  received  ) 

void libtorrent::bt_peer_connection::on_interested ( int  received  ) 

void libtorrent::bt_peer_connection::on_not_interested ( int  received  ) 

void libtorrent::bt_peer_connection::on_have ( int  received  ) 

void libtorrent::bt_peer_connection::on_bitfield ( int  received  ) 

void libtorrent::bt_peer_connection::on_request ( int  received  ) 

void libtorrent::bt_peer_connection::on_piece ( int  received  ) 

void libtorrent::bt_peer_connection::on_cancel ( int  received  ) 

void libtorrent::bt_peer_connection::on_dht_port ( int  received  ) 

void libtorrent::bt_peer_connection::on_extended ( int  received  ) 

void libtorrent::bt_peer_connection::on_extended_handshake (  ) 

void libtorrent::bt_peer_connection::write_choke (  )  [virtual]

void libtorrent::bt_peer_connection::write_unchoke (  )  [virtual]

void libtorrent::bt_peer_connection::write_interested (  )  [virtual]

void libtorrent::bt_peer_connection::write_not_interested (  )  [virtual]

void libtorrent::bt_peer_connection::write_request ( peer_request const &  r  )  [virtual]

void libtorrent::bt_peer_connection::write_cancel ( peer_request const &  r  )  [virtual]

void libtorrent::bt_peer_connection::write_bitfield ( std::vector< bool > const &  bitfield  ) 

void libtorrent::bt_peer_connection::write_have ( int  index  )  [virtual]

void libtorrent::bt_peer_connection::write_piece ( peer_request const &  r  )  [virtual]

void libtorrent::bt_peer_connection::write_handshake (  ) 

void libtorrent::bt_peer_connection::write_extensions (  ) 

void libtorrent::bt_peer_connection::write_chat_message ( const std::string &  msg  ) 

void libtorrent::bt_peer_connection::write_metadata ( std::pair< int, int >  req  ) 

void libtorrent::bt_peer_connection::write_metadata_request ( std::pair< int, int >  req  ) 

void libtorrent::bt_peer_connection::write_keepalive (  )  [virtual]

void libtorrent::bt_peer_connection::write_dht_port ( int  listen_port  ) 

void libtorrent::bt_peer_connection::on_connected (  )  [inline, virtual]

Implements libtorrent::peer_connection.

Definition at line 197 of file bt_peer_connection.hpp.

void libtorrent::bt_peer_connection::on_metadata (  )  [virtual]

void libtorrent::bt_peer_connection::check_invariant (  )  const

Reimplemented from libtorrent::peer_connection.

Definition at line 1394 of file bt_peer_connection.cpp.

References libtorrent::check_invariant(), m_in_constructor, and m_payloads.

bool libtorrent::bt_peer_connection::dispatch_message ( int  received  )  [private]

boost::optional< piece_block_progress > libtorrent::bt_peer_connection::downloading_piece_progress (  )  const [private, virtual]

static bool libtorrent::bt_peer_connection::range_below_zero ( const range r  )  [inline, static, private]

Definition at line 252 of file bt_peer_connection.hpp.

References libtorrent::bt_peer_connection::range::start.

Referenced by on_sent().


Friends And Related Function Documentation

friend class invariant_access [friend]

Reimplemented from libtorrent::peer_connection.

Definition at line 85 of file bt_peer_connection.hpp.


Member Data Documentation

Reimplemented from libtorrent::peer_connection.

Definition at line 202 of file bt_peer_connection.hpp.

Definition at line 226 of file bt_peer_connection.hpp.

Referenced by get_peer_info(), on_extended_handshake(), and on_receive().

Reimplemented from libtorrent::peer_connection.

Definition at line 231 of file bt_peer_connection.hpp.

Definition at line 254 of file bt_peer_connection.hpp.

Referenced by check_invariant(), on_sent(), and write_piece().

Definition at line 260 of file bt_peer_connection.hpp.

Referenced by on_receive(), and write_extensions().

Definition at line 262 of file bt_peer_connection.hpp.

Referenced by on_receive().

Definition at line 267 of file bt_peer_connection.hpp.

Referenced by write_bitfield().

Reimplemented from libtorrent::peer_connection.

Definition at line 269 of file bt_peer_connection.hpp.

Referenced by bt_peer_connection(), and check_invariant().


The documentation for this class was generated from the following files:

Generated on Sun May 25 00:21:40 2008 by  doxygen 1.5.6