libtorrent::peer_connection Class Reference

#include <peer_connection.hpp>

Inheritance diagram for libtorrent::peer_connection:

libtorrent::bt_peer_connection libtorrent::web_peer_connection

List of all members.

Public Types

enum  channels { upload_channel, download_channel, num_channels }

Public Member Functions

 peer_connection (aux::session_impl &ses, boost::weak_ptr< torrent > t, boost::shared_ptr< stream_socket > s, tcp::endpoint const &remote, tcp::endpoint const &proxy)
 peer_connection (aux::session_impl &ses, boost::shared_ptr< stream_socket > s)
virtual ~peer_connection ()
void add_extension (boost::shared_ptr< peer_plugin >)
void init ()
virtual void on_metadata ()
void set_upload_limit (int limit)
void set_download_limit (int limit)
bool prefer_whole_pieces () const
void prefer_whole_pieces (bool b)
bool request_large_blocks () const
void request_large_blocks (bool b)
void set_non_prioritized (bool b)
void announce_piece (int index)
bool can_write () const
bool can_read () const
bool is_seed () const
bool has_timed_out () const
void keep_alive ()
peer_id const & pid () const
void set_pid (const peer_id &pid)
bool has_piece (int i) const
const std::deque< piece_block > & download_queue () const
const std::deque< piece_block > & request_queue () const
const std::deque< peer_request > & upload_queue () const
bool is_interesting () const
bool is_choked () const
bool is_peer_interested () const
bool has_peer_choked () const
boost::weak_ptr< torrentassociated_torrent () const
const statstatistics () const
void add_stat (size_type downloaded, size_type uploaded)
void second_tick (float tick_interval)
boost::shared_ptr< stream_socketget_socket () const
tcp::endpoint const & remote () const
tcp::endpoint const & proxy () const
std::vector< bool > const & get_bitfield () const
void disconnect ()
bool is_disconnecting () const
void on_connection_complete (asio::error_code const &e)
bool is_connecting () const
bool is_queued () const
void connect ()
void reset_upload_quota ()
size_type total_free_upload () const
void add_free_upload (size_type free_upload)
void received_valid_data (int index)
void received_invalid_data (int index)
int trust_points () const
size_type share_diff () const
bool is_local () const
void set_failed ()
bool failed () const
int desired_queue_size () const
void incoming_keepalive ()
void incoming_choke ()
void incoming_unchoke ()
void incoming_interested ()
void incoming_not_interested ()
void incoming_have (int piece_index)
void incoming_bitfield (std::vector< bool > const &bitfield)
void incoming_request (peer_request const &r)
void incoming_piece (peer_request const &p, char const *data)
void incoming_piece_fragment ()
void incoming_cancel (peer_request const &r)
void incoming_dht_port (int listen_port)
void send_choke ()
void send_unchoke ()
void send_interested ()
void send_not_interested ()
void add_request (piece_block const &b)
void cancel_request (piece_block const &b)
void send_block_requests ()
int max_assignable_bandwidth (int channel) const
void assign_bandwidth (int channel, int amount)
void expire_bandwidth (int channel, int amount)
void check_invariant () const
virtual void get_peer_info (peer_info &p) const =0
virtual bool in_handshake () const =0
virtual boost::optional
< piece_block_progress
downloading_piece_progress () const
void send_buffer (char const *begin, char const *end)
buffer::interval allocate_send_buffer (int size)
void setup_send ()
void set_country (char const *c)
bool has_country () const

Public Attributes

boost::posix_time::ptime m_last_choke
bool m_in_constructor

Protected Types

typedef std::list
< boost::shared_ptr
< peer_plugin > > 
extension_list_t

Protected Member Functions

virtual void write_choke ()=0
virtual void write_unchoke ()=0
virtual void write_interested ()=0
virtual void write_not_interested ()=0
virtual void write_request (peer_request const &r)=0
virtual void write_cancel (peer_request const &r)=0
virtual void write_have (int index)=0
virtual void write_keepalive ()=0
virtual void write_piece (peer_request const &r)=0
virtual void on_connected ()=0
virtual void on_tick ()
virtual void on_receive (asio::error_code const &error, std::size_t bytes_transferred)=0
virtual void on_sent (asio::error_code const &error, std::size_t bytes_transferred)=0
int send_buffer_size () const
buffer::const_interval receive_buffer () const
void cut_receive_buffer (int size, int packet_size)
void reset_recv_buffer (int packet_size)
int packet_size () const
bool packet_finished () const
void setup_receive ()
void attach_to_torrent (sha1_hash const &ih)
bool verify_piece (peer_request const &p) const
boost::intrusive_ptr
< peer_connection
self ()
void on_send_data (asio::error_code const &error, std::size_t bytes_transferred)
void on_receive_data (asio::error_code const &error, std::size_t bytes_transferred)
void set_timeout (int s)

Protected Attributes

bandwidth_limit m_bandwidth_limit [num_channels]
stat m_statistics
aux::session_implm_ses
int m_max_out_request_queue
extension_list_t m_extensions
char m_country [2]

Private Member Functions

void fill_send_buffer ()

Private Attributes

int m_timeout
boost::posix_time::ptime m_last_piece
int m_packet_size
int m_recv_pos
std::vector< char > m_recv_buffer
std::vector< char > m_send_buffer [2]
int m_current_send_buffer
int m_write_pos
boost::posix_time::ptime m_last_receive
boost::posix_time::ptime m_last_sent
boost::shared_ptr< stream_socketm_socket
tcp::endpoint m_remote
tcp::endpoint m_remote_proxy
boost::weak_ptr< torrentm_torrent
bool m_active
peer_id m_peer_id
bool m_peer_interested
bool m_peer_choked
bool m_interesting
bool m_choked
bool m_failed
std::vector< boolm_have_piece
int m_num_pieces
std::deque< peer_requestm_requests
std::deque< piece_blockm_request_queue
std::deque< piece_blockm_download_queue
int m_desired_queue_size
size_type m_free_upload
int m_trust_points
bool m_assume_fifo
int m_num_invalid_requests
bool m_disconnecting
boost::posix_time::ptime m_became_uninterested
boost::posix_time::ptime m_became_uninteresting
bool m_connecting
bool m_queued
bool m_writing
bool m_reading
bool m_prefer_whole_pieces
bool m_request_large_blocks
bool m_non_prioritized
boost::detail::atomic_count m_refs
int m_upload_limit
int m_download_limit

Friends

class invariant_access
void intrusive_ptr_add_ref (peer_connection const *)
void intrusive_ptr_release (peer_connection const *)


Detailed Description

Definition at line 98 of file peer_connection.hpp.


Member Typedef Documentation

typedef std::list<boost::shared_ptr<peer_plugin> > libtorrent::peer_connection::extension_list_t [protected]

Definition at line 431 of file peer_connection.hpp.


Member Enumeration Documentation

Enumerator:
upload_channel 
download_channel 
num_channels 

Definition at line 106 of file peer_connection.hpp.


Constructor & Destructor Documentation

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

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

libtorrent::peer_connection::~peer_connection (  )  [virtual]

Definition at line 246 of file peer_connection.cpp.

References m_disconnecting, and m_torrent.


Member Function Documentation

void libtorrent::peer_connection::add_extension ( boost::shared_ptr< peer_plugin ext  ) 

Definition at line 182 of file peer_connection.cpp.

References m_extensions.

Referenced by libtorrent::torrent::attach_peer().

void libtorrent::peer_connection::init (  ) 

Definition at line 188 of file peer_connection.cpp.

References index, INVARIANT_CHECK, m_have_piece, m_num_pieces, and m_torrent.

Referenced by attach_to_torrent().

virtual void libtorrent::peer_connection::on_metadata (  )  [inline, virtual]

Reimplemented in libtorrent::bt_peer_connection.

Definition at line 143 of file peer_connection.hpp.

void libtorrent::peer_connection::set_upload_limit ( int  limit  ) 

void libtorrent::peer_connection::set_download_limit ( int  limit  ) 

bool libtorrent::peer_connection::prefer_whole_pieces (  )  const [inline]

void libtorrent::peer_connection::prefer_whole_pieces ( bool  b  )  [inline]

Definition at line 151 of file peer_connection.hpp.

bool libtorrent::peer_connection::request_large_blocks (  )  const [inline]

void libtorrent::peer_connection::request_large_blocks ( bool  b  )  [inline]

Definition at line 157 of file peer_connection.hpp.

void libtorrent::peer_connection::set_non_prioritized ( bool  b  )  [inline]

void libtorrent::peer_connection::announce_piece ( int  index  ) 

Definition at line 265 of file peer_connection.cpp.

References has_piece(), m_torrent, and write_have().

bool libtorrent::peer_connection::can_write (  )  const

bool libtorrent::peer_connection::can_read (  )  const

bool libtorrent::peer_connection::is_seed (  )  const

bool libtorrent::peer_connection::has_timed_out (  )  const

void libtorrent::peer_connection::keep_alive (  ) 

peer_id const& libtorrent::peer_connection::pid (  )  const [inline]

void libtorrent::peer_connection::set_pid ( const peer_id pid  )  [inline]

Definition at line 180 of file peer_connection.hpp.

Referenced by libtorrent::bt_peer_connection::on_receive().

bool libtorrent::peer_connection::has_piece ( int  i  )  const

Definition at line 284 of file peer_connection.cpp.

References INVARIANT_CHECK, m_have_piece, and m_torrent.

Referenced by announce_piece().

std::deque< piece_block > const & libtorrent::peer_connection::download_queue (  )  const

std::deque< piece_block > const & libtorrent::peer_connection::request_queue (  )  const

Definition at line 296 of file peer_connection.cpp.

References m_request_queue.

Referenced by libtorrent::request_a_block().

std::deque< peer_request > const & libtorrent::peer_connection::upload_queue (  )  const

bool libtorrent::peer_connection::is_interesting (  )  const [inline]

bool libtorrent::peer_connection::is_choked (  )  const [inline]

bool libtorrent::peer_connection::is_peer_interested (  )  const [inline]

bool libtorrent::peer_connection::has_peer_choked (  )  const [inline]

boost::weak_ptr<torrent> libtorrent::peer_connection::associated_torrent (  )  const [inline]

const stat& libtorrent::peer_connection::statistics (  )  const [inline]

void libtorrent::peer_connection::add_stat ( size_type  downloaded,
size_type  uploaded 
)

void libtorrent::peer_connection::second_tick ( float  tick_interval  ) 

boost::shared_ptr<stream_socket> libtorrent::peer_connection::get_socket (  )  const [inline]

tcp::endpoint const& libtorrent::peer_connection::remote (  )  const [inline]

tcp::endpoint const& libtorrent::peer_connection::proxy (  )  const [inline]

std::vector< bool > const & libtorrent::peer_connection::get_bitfield (  )  const

void libtorrent::peer_connection::disconnect (  ) 

bool libtorrent::peer_connection::is_disconnecting (  )  const [inline]

void libtorrent::peer_connection::on_connection_complete ( asio::error_code const &  e  ) 

bool libtorrent::peer_connection::is_connecting (  )  const [inline]

bool libtorrent::peer_connection::is_queued (  )  const [inline]

void libtorrent::peer_connection::connect (  ) 

void libtorrent::peer_connection::reset_upload_quota (  ) 

size_type libtorrent::peer_connection::total_free_upload (  )  const

void libtorrent::peer_connection::add_free_upload ( size_type  free_upload  ) 

void libtorrent::peer_connection::received_valid_data ( int  index  ) 

void libtorrent::peer_connection::received_invalid_data ( int  index  ) 

int libtorrent::peer_connection::trust_points (  )  const

Definition at line 359 of file peer_connection.cpp.

References m_trust_points.

size_type libtorrent::peer_connection::share_diff (  )  const

bool libtorrent::peer_connection::is_local (  )  const [inline]

void libtorrent::peer_connection::set_failed (  )  [inline]

Definition at line 256 of file peer_connection.hpp.

Referenced by libtorrent::aux::session_impl::second_tick().

bool libtorrent::peer_connection::failed (  )  const [inline]

Definition at line 257 of file peer_connection.hpp.

Referenced by libtorrent::policy::connection_closed().

int libtorrent::peer_connection::desired_queue_size (  )  const [inline]

Definition at line 259 of file peer_connection.hpp.

Referenced by libtorrent::request_a_block().

void libtorrent::peer_connection::incoming_keepalive (  ) 

void libtorrent::peer_connection::incoming_choke (  ) 

void libtorrent::peer_connection::incoming_unchoke (  ) 

void libtorrent::peer_connection::incoming_interested (  ) 

void libtorrent::peer_connection::incoming_not_interested (  ) 

void libtorrent::peer_connection::incoming_have ( int  piece_index  ) 

void libtorrent::peer_connection::incoming_bitfield ( std::vector< bool > const &  bitfield  ) 

void libtorrent::peer_connection::incoming_request ( peer_request const &  r  ) 

void libtorrent::peer_connection::incoming_piece ( peer_request const &  p,
char const *  data 
)

void libtorrent::peer_connection::incoming_piece_fragment (  ) 

void libtorrent::peer_connection::incoming_cancel ( peer_request const &  r  ) 

void libtorrent::peer_connection::incoming_dht_port ( int  listen_port  ) 

void libtorrent::peer_connection::send_choke (  ) 

void libtorrent::peer_connection::send_unchoke (  ) 

void libtorrent::peer_connection::send_interested (  ) 

void libtorrent::peer_connection::send_not_interested (  ) 

void libtorrent::peer_connection::add_request ( piece_block const &  b  ) 

void libtorrent::peer_connection::cancel_request ( piece_block const &  b  ) 

void libtorrent::peer_connection::send_block_requests (  ) 

int libtorrent::peer_connection::max_assignable_bandwidth ( int  channel  )  const [inline]

Definition at line 302 of file peer_connection.hpp.

void libtorrent::peer_connection::assign_bandwidth ( int  channel,
int  amount 
)

void libtorrent::peer_connection::expire_bandwidth ( int  channel,
int  amount 
)

void libtorrent::peer_connection::check_invariant (  )  const

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

virtual bool libtorrent::peer_connection::in_handshake (  )  const [pure virtual]

virtual boost::optional<piece_block_progress> libtorrent::peer_connection::downloading_piece_progress (  )  const [inline, virtual]

void libtorrent::peer_connection::send_buffer ( char const *  begin,
char const *  end 
)

buffer::interval libtorrent::peer_connection::allocate_send_buffer ( int  size  ) 

void libtorrent::peer_connection::setup_send (  ) 

void libtorrent::peer_connection::set_country ( char const *  c  )  [inline]

Definition at line 339 of file peer_connection.hpp.

bool libtorrent::peer_connection::has_country (  )  const [inline]

Definition at line 345 of file peer_connection.hpp.

virtual void libtorrent::peer_connection::write_choke (  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::write_unchoke (  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::write_interested (  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::write_not_interested (  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::write_request ( peer_request const &  r  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::write_cancel ( peer_request const &  r  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::write_have ( int  index  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::write_keepalive (  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::write_piece ( peer_request const &  r  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::on_connected (  )  [protected, pure virtual]

virtual void libtorrent::peer_connection::on_tick (  )  [inline, protected, virtual]

Definition at line 360 of file peer_connection.hpp.

Referenced by second_tick().

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

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

int libtorrent::peer_connection::send_buffer_size (  )  const [inline, protected]

buffer::const_interval libtorrent::peer_connection::receive_buffer (  )  const [inline, protected]

void libtorrent::peer_connection::cut_receive_buffer ( int  size,
int  packet_size 
) [protected]

void libtorrent::peer_connection::reset_recv_buffer ( int  packet_size  )  [protected]

int libtorrent::peer_connection::packet_size (  )  const [inline, protected]

bool libtorrent::peer_connection::packet_finished (  )  const [inline, protected]

void libtorrent::peer_connection::setup_receive (  )  [protected]

void libtorrent::peer_connection::attach_to_torrent ( sha1_hash const &  ih  )  [protected]

bool libtorrent::peer_connection::verify_piece ( peer_request const &  p  )  const [protected]

boost::intrusive_ptr<peer_connection> libtorrent::peer_connection::self (  )  [inline, protected]

Definition at line 410 of file peer_connection.hpp.

void libtorrent::peer_connection::on_send_data ( asio::error_code const &  error,
std::size_t  bytes_transferred 
) [protected]

void libtorrent::peer_connection::on_receive_data ( asio::error_code const &  error,
std::size_t  bytes_transferred 
) [protected]

void libtorrent::peer_connection::set_timeout ( int  s  )  [inline, protected]

void libtorrent::peer_connection::fill_send_buffer (  )  [private]


Friends And Related Function Documentation

friend class invariant_access [friend]

Reimplemented in libtorrent::bt_peer_connection, and libtorrent::web_peer_connection.

Definition at line 101 of file peer_connection.hpp.

void intrusive_ptr_add_ref ( peer_connection const *  c  )  [friend]

void intrusive_ptr_release ( peer_connection const *  c  )  [friend]


Member Data Documentation

Reimplemented in libtorrent::bt_peer_connection.

Definition at line 312 of file peer_connection.hpp.

Referenced by send_choke().

Reimplemented in libtorrent::bt_peer_connection.

Definition at line 446 of file peer_connection.hpp.

Referenced by has_timed_out(), and keep_alive().

boost::posix_time::ptime libtorrent::peer_connection::m_last_piece [private]

Definition at line 450 of file peer_connection.hpp.

Referenced by incoming_piece_fragment(), second_tick(), and send_block_requests().

std::vector<char> libtorrent::peer_connection::m_recv_buffer [private]

std::vector<char> libtorrent::peer_connection::m_send_buffer[2] [private]

Definition at line 474 of file peer_connection.hpp.

Referenced by check_invariant(), on_send_data(), and setup_send().

boost::posix_time::ptime libtorrent::peer_connection::m_last_receive [private]

Definition at line 477 of file peer_connection.hpp.

Referenced by has_timed_out(), on_connection_complete(), and on_receive_data().

boost::posix_time::ptime libtorrent::peer_connection::m_last_sent [private]

Definition at line 478 of file peer_connection.hpp.

Referenced by keep_alive(), and on_send_data().

Definition at line 487 of file peer_connection.hpp.

Referenced by connect().

boost::weak_ptr<torrent> libtorrent::peer_connection::m_torrent [private]

Definition at line 498 of file peer_connection.hpp.

Definition at line 501 of file peer_connection.hpp.

Referenced by connect(), incoming_piece(), incoming_request(), and peer_connection().

Definition at line 509 of file peer_connection.hpp.

Referenced by incoming_choke(), and incoming_unchoke().

Definition at line 512 of file peer_connection.hpp.

Referenced by has_timed_out(), send_interested(), and send_not_interested().

Definition at line 515 of file peer_connection.hpp.

Referenced by fill_send_buffer(), incoming_request(), send_choke(), and send_unchoke().

Definition at line 521 of file peer_connection.hpp.

Definition at line 546 of file peer_connection.hpp.

Referenced by incoming_piece(), second_tick(), and send_block_requests().

Definition at line 554 of file peer_connection.hpp.

Referenced by add_free_upload(), second_tick(), share_diff(), and total_free_upload().

Definition at line 562 of file peer_connection.hpp.

Referenced by received_invalid_data(), received_valid_data(), and trust_points().

Definition at line 569 of file peer_connection.hpp.

Referenced by incoming_piece(), and second_tick().

Definition at line 578 of file peer_connection.hpp.

Referenced by fill_send_buffer(), incoming_request(), and send_choke().

boost::posix_time::ptime libtorrent::peer_connection::m_became_uninterested [private]

Definition at line 586 of file peer_connection.hpp.

Referenced by has_timed_out(), and incoming_not_interested().

boost::posix_time::ptime libtorrent::peer_connection::m_became_uninteresting [private]

Definition at line 590 of file peer_connection.hpp.

Referenced by has_timed_out(), and send_not_interested().

Definition at line 605 of file peer_connection.hpp.

Referenced by connect().

Definition at line 609 of file peer_connection.hpp.

Referenced by assign_bandwidth(), on_send_data(), and setup_send().

Definition at line 610 of file peer_connection.hpp.

Referenced by assign_bandwidth(), on_receive_data(), and setup_receive().

Definition at line 617 of file peer_connection.hpp.

Definition at line 625 of file peer_connection.hpp.

Referenced by second_tick(), send_block_requests(), and verify_piece().

Definition at line 631 of file peer_connection.hpp.

Referenced by setup_receive().

boost::detail::atomic_count libtorrent::peer_connection::m_refs [mutable, private]

Definition at line 636 of file peer_connection.hpp.

Referenced by second_tick(), and set_upload_limit().

Definition at line 637 of file peer_connection.hpp.

Referenced by set_download_limit().

Reimplemented in libtorrent::bt_peer_connection.

Definition at line 641 of file peer_connection.hpp.

Referenced by check_invariant().


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

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