switched over to asio from boost-1.35
This commit is contained in:
@@ -151,7 +151,7 @@ namespace libtorrent
|
||||
|
||||
void async_accept(boost::shared_ptr<socket_acceptor> const& listener);
|
||||
void on_incoming_connection(boost::shared_ptr<socket_type> const& s
|
||||
, boost::weak_ptr<socket_acceptor> listener, asio::error_code const& e);
|
||||
, boost::weak_ptr<socket_acceptor> listener, error_code const& e);
|
||||
|
||||
// must be locked to access the data
|
||||
// in this struct
|
||||
@@ -498,7 +498,7 @@ namespace libtorrent
|
||||
// NAT or not.
|
||||
bool m_incoming_connection;
|
||||
|
||||
void second_tick(asio::error_code const& e);
|
||||
void second_tick(error_code const& e);
|
||||
void recalculate_auto_managed_torrents();
|
||||
void recalculate_unchoke_slots(int congested_torrents
|
||||
, int uncongested_torrents);
|
||||
@@ -528,7 +528,7 @@ namespace libtorrent
|
||||
|
||||
udp_socket m_dht_socket;
|
||||
|
||||
void on_receive_udp(asio::error_code const& e
|
||||
void on_receive_udp(error_code const& e
|
||||
, udp::endpoint const& ep, char const* buf, int len);
|
||||
#endif
|
||||
|
||||
|
@@ -256,12 +256,12 @@ private:
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
asio::error_code ec;
|
||||
error_code ec;
|
||||
m_history_timer.expires_at(e.expires_at, ec);
|
||||
m_history_timer.async_wait(bind(&bandwidth_manager::on_history_expire, this, _1));
|
||||
}
|
||||
|
||||
void on_history_expire(asio::error_code const& e)
|
||||
void on_history_expire(error_code const& e)
|
||||
{
|
||||
if (e) return;
|
||||
|
||||
@@ -298,7 +298,7 @@ private:
|
||||
// now, wait for the next chunk to expire
|
||||
if (!m_history.empty() && !m_abort)
|
||||
{
|
||||
asio::error_code ec;
|
||||
error_code ec;
|
||||
m_history_timer.expires_at(m_history.back().expires_at, ec);
|
||||
m_history_timer.async_wait(bind(&bandwidth_manager::on_history_expire, this, _1));
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ namespace libtorrent
|
||||
int common_bits(unsigned char const* b1
|
||||
, unsigned char const* b2, int n);
|
||||
|
||||
TORRENT_EXPORT address guess_local_address(asio::io_service&);
|
||||
TORRENT_EXPORT address guess_local_address(io_service&);
|
||||
|
||||
typedef boost::function<void(udp::endpoint const& from
|
||||
, char* buffer, int size)> receive_handler_t;
|
||||
@@ -59,11 +59,11 @@ namespace libtorrent
|
||||
class TORRENT_EXPORT broadcast_socket
|
||||
{
|
||||
public:
|
||||
broadcast_socket(asio::io_service& ios, udp::endpoint const& multicast_endpoint
|
||||
broadcast_socket(io_service& ios, udp::endpoint const& multicast_endpoint
|
||||
, receive_handler_t const& handler, bool loopback = true);
|
||||
~broadcast_socket() { close(); }
|
||||
|
||||
void send(char const* buffer, int size, asio::error_code& ec);
|
||||
void send(char const* buffer, int size, error_code& ec);
|
||||
void close();
|
||||
|
||||
private:
|
||||
@@ -77,12 +77,12 @@ namespace libtorrent
|
||||
void close()
|
||||
{
|
||||
if (!socket) return;
|
||||
asio::error_code ec;
|
||||
error_code ec;
|
||||
socket->close(ec);
|
||||
}
|
||||
};
|
||||
|
||||
void on_receive(socket_entry* s, asio::error_code const& ec
|
||||
void on_receive(socket_entry* s, error_code const& ec
|
||||
, std::size_t bytes_transferred);
|
||||
void open_unicast_socket(io_service& ios, address const& addr);
|
||||
void open_multicast_socket(io_service& ios, address const& addr
|
||||
|
@@ -141,9 +141,9 @@ namespace libtorrent
|
||||
// called from the main loop when this connection has any
|
||||
// work to do.
|
||||
|
||||
void on_sent(asio::error_code const& error
|
||||
void on_sent(error_code const& error
|
||||
, std::size_t bytes_transferred);
|
||||
void on_receive(asio::error_code const& error
|
||||
void on_receive(error_code const& error
|
||||
, std::size_t bytes_transferred);
|
||||
|
||||
virtual void get_specific_peer_info(peer_info& p) const;
|
||||
|
@@ -34,12 +34,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#define TORRENT_CHAINED_BUFFER_HPP_INCLUDED
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <asio/buffer.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <list>
|
||||
#include <cstring>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
namespace asio = boost::asio;
|
||||
|
||||
struct chained_buffer
|
||||
{
|
||||
chained_buffer(): m_bytes(0), m_capacity(0) {}
|
||||
|
@@ -71,7 +71,7 @@ public:
|
||||
private:
|
||||
|
||||
void try_connect();
|
||||
void on_timeout(asio::error_code const& e);
|
||||
void on_timeout(error_code const& e);
|
||||
|
||||
struct entry
|
||||
{
|
||||
|
@@ -149,7 +149,7 @@ namespace libtorrent
|
||||
// of disk io jobs
|
||||
struct disk_io_thread : boost::noncopyable
|
||||
{
|
||||
disk_io_thread(asio::io_service& ios, int block_size = 16 * 1024);
|
||||
disk_io_thread(io_service& ios, int block_size = 16 * 1024);
|
||||
~disk_io_thread();
|
||||
|
||||
#ifdef TORRENT_STATS
|
||||
@@ -292,7 +292,7 @@ namespace libtorrent
|
||||
size_type m_writes;
|
||||
size_type m_blocks_written;
|
||||
|
||||
asio::io_service& m_ios;
|
||||
io_service& m_ios;
|
||||
|
||||
// thread for performing blocking disk io operations
|
||||
boost::thread m_disk_io_thread;
|
||||
|
@@ -56,10 +56,10 @@ namespace libtorrent
|
||||
|
||||
// returns a list of the configured IP interfaces
|
||||
// on the machine
|
||||
TORRENT_EXPORT std::vector<ip_interface> enum_net_interfaces(asio::io_service& ios
|
||||
, asio::error_code& ec);
|
||||
TORRENT_EXPORT std::vector<ip_interface> enum_net_interfaces(io_service& ios
|
||||
, error_code& ec);
|
||||
|
||||
TORRENT_EXPORT std::vector<ip_route> enum_routes(asio::io_service& ios, asio::error_code& ec);
|
||||
TORRENT_EXPORT std::vector<ip_route> enum_routes(io_service& ios, error_code& ec);
|
||||
|
||||
// returns true if the specified address is on the same
|
||||
// local network as the specified interface
|
||||
@@ -67,11 +67,11 @@ namespace libtorrent
|
||||
|
||||
// returns true if the specified address is on the same
|
||||
// local network as us
|
||||
TORRENT_EXPORT bool in_local_network(asio::io_service& ios, address const& addr
|
||||
, asio::error_code& ec);
|
||||
TORRENT_EXPORT bool in_local_network(io_service& ios, address const& addr
|
||||
, error_code& ec);
|
||||
|
||||
TORRENT_EXPORT address get_default_gateway(asio::io_service& ios
|
||||
, asio::error_code& ec);
|
||||
TORRENT_EXPORT address get_default_gateway(io_service& ios
|
||||
, error_code& ec);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -59,7 +59,7 @@ namespace libtorrent
|
||||
struct http_connection;
|
||||
class connection_queue;
|
||||
|
||||
typedef boost::function<void(asio::error_code const&
|
||||
typedef boost::function<void(error_code const&
|
||||
, http_parser const&, char const* data, int size)> http_handler;
|
||||
|
||||
typedef boost::function<void(http_connection&)> http_connect_handler;
|
||||
@@ -70,7 +70,7 @@ typedef boost::function<void(http_connection&)> http_connect_handler;
|
||||
// will always be 0
|
||||
struct http_connection : boost::enable_shared_from_this<http_connection>, boost::noncopyable
|
||||
{
|
||||
http_connection(asio::io_service& ios, connection_queue& cc
|
||||
http_connection(io_service& ios, connection_queue& cc
|
||||
, http_handler const& handler, bool bottled = true
|
||||
, http_connect_handler const& ch = http_connect_handler())
|
||||
: m_sock(ios)
|
||||
@@ -121,19 +121,19 @@ struct http_connection : boost::enable_shared_from_this<http_connection>, boost:
|
||||
|
||||
private:
|
||||
|
||||
void on_resolve(asio::error_code const& e
|
||||
void on_resolve(error_code const& e
|
||||
, tcp::resolver::iterator i);
|
||||
void connect(int ticket, tcp::endpoint target_address);
|
||||
void on_connect_timeout();
|
||||
void on_connect(asio::error_code const& e
|
||||
void on_connect(error_code const& e
|
||||
/* , tcp::resolver::iterator i*/);
|
||||
void on_write(asio::error_code const& e);
|
||||
void on_read(asio::error_code const& e, std::size_t bytes_transferred);
|
||||
void on_write(error_code const& e);
|
||||
void on_read(error_code const& e, std::size_t bytes_transferred);
|
||||
static void on_timeout(boost::weak_ptr<http_connection> p
|
||||
, asio::error_code const& e);
|
||||
void on_assign_bandwidth(asio::error_code const& e);
|
||||
, error_code const& e);
|
||||
void on_assign_bandwidth(error_code const& e);
|
||||
|
||||
void callback(asio::error_code const& e, char const* data = 0, int size = 0);
|
||||
void callback(error_code const& e, char const* data = 0, int size = 0);
|
||||
|
||||
std::vector<char> m_recvbuffer;
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
|
@@ -41,7 +41,7 @@ class http_stream : public proxy_base
|
||||
{
|
||||
public:
|
||||
|
||||
explicit http_stream(asio::io_service& io_service)
|
||||
explicit http_stream(io_service& io_service)
|
||||
: proxy_base(io_service)
|
||||
, m_no_connect(false)
|
||||
{}
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
m_password = password;
|
||||
}
|
||||
|
||||
typedef boost::function<void(asio::error_code const&)> handler_type;
|
||||
typedef boost::function<void(error_code const&)> handler_type;
|
||||
|
||||
template <class Handler>
|
||||
void async_connect(endpoint_type const& endpoint, Handler const& handler)
|
||||
@@ -80,11 +80,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void name_lookup(asio::error_code const& e, tcp::resolver::iterator i
|
||||
void name_lookup(error_code const& e, tcp::resolver::iterator i
|
||||
, boost::shared_ptr<handler_type> h);
|
||||
void connected(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void connected(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake1(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake2(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
|
||||
// send and receive buffer
|
||||
std::vector<char> m_buffer;
|
||||
|
@@ -82,7 +82,7 @@ namespace libtorrent
|
||||
boost::intrusive_ptr<http_tracker_connection> self()
|
||||
{ return boost::intrusive_ptr<http_tracker_connection>(this); }
|
||||
|
||||
void on_response(asio::error_code const& ec, http_parser const& parser
|
||||
void on_response(error_code const& ec, http_parser const& parser
|
||||
, char const* data, int size);
|
||||
|
||||
virtual void on_timeout() {}
|
||||
|
@@ -34,14 +34,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#define TORRENT_INSTANTIATE_CONNECTION
|
||||
|
||||
#include "libtorrent/socket_type.hpp"
|
||||
#include <asio/io_service.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
struct proxy_settings;
|
||||
|
||||
bool instantiate_connection(asio::io_service& ios
|
||||
bool instantiate_connection(io_service& ios
|
||||
, proxy_settings const& ps, socket_type& s);
|
||||
}
|
||||
|
||||
|
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
private:
|
||||
void done();
|
||||
void invoke(node_id const& id, asio::ip::udp::endpoint addr);
|
||||
void invoke(node_id const& id, udp::endpoint addr);
|
||||
|
||||
closest_nodes(
|
||||
node_id target
|
||||
|
@@ -53,6 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "libtorrent/session_settings.hpp"
|
||||
#include "libtorrent/session_status.hpp"
|
||||
#include "libtorrent/udp_socket.hpp"
|
||||
#include "libtorrent/socket.hpp"
|
||||
|
||||
namespace libtorrent { namespace dht
|
||||
{
|
||||
@@ -95,13 +96,13 @@ namespace libtorrent { namespace dht
|
||||
boost::intrusive_ptr<dht_tracker> self()
|
||||
{ return boost::intrusive_ptr<dht_tracker>(this); }
|
||||
|
||||
void on_name_lookup(asio::error_code const& e
|
||||
void on_name_lookup(error_code const& e
|
||||
, udp::resolver::iterator host);
|
||||
void on_router_name_lookup(asio::error_code const& e
|
||||
void on_router_name_lookup(error_code const& e
|
||||
, udp::resolver::iterator host);
|
||||
void connection_timeout(asio::error_code const& e);
|
||||
void refresh_timeout(asio::error_code const& e);
|
||||
void tick(asio::error_code const& e);
|
||||
void connection_timeout(error_code const& e);
|
||||
void refresh_timeout(error_code const& e);
|
||||
void tick(error_code const& e);
|
||||
|
||||
void on_bootstrap();
|
||||
void send_packet(msg const& m);
|
||||
|
@@ -48,8 +48,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace libtorrent { namespace dht
|
||||
{
|
||||
|
||||
using asio::ip::udp;
|
||||
|
||||
typedef std::vector<char> packet_t;
|
||||
|
||||
class rpc_manager;
|
||||
|
@@ -36,15 +36,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <string>
|
||||
#include <libtorrent/kademlia/node_id.hpp>
|
||||
#include "libtorrent/entry.hpp"
|
||||
#include <asio/ip/udp.hpp>
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
|
||||
namespace libtorrent {
|
||||
namespace dht {
|
||||
|
||||
typedef std::vector<char> packet_t;
|
||||
|
||||
using asio::ip::udp;
|
||||
|
||||
namespace messages
|
||||
{
|
||||
enum { ping = 0, find_node = 1, get_peers = 2, announce_peer = 3, error = 4 };
|
||||
|
@@ -56,8 +56,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace libtorrent { namespace dht
|
||||
{
|
||||
|
||||
using asio::ip::udp;
|
||||
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_DECLARE_LOG(node);
|
||||
#endif
|
||||
|
@@ -41,11 +41,11 @@ namespace libtorrent { namespace dht
|
||||
|
||||
struct node_entry
|
||||
{
|
||||
node_entry(node_id const& id_, asio::ip::udp::endpoint addr_)
|
||||
node_entry(node_id const& id_, udp::endpoint addr_)
|
||||
: id(id_)
|
||||
, addr(addr_)
|
||||
, fail_count(0) {}
|
||||
node_entry(asio::ip::udp::endpoint addr_)
|
||||
node_entry(udp::endpoint addr_)
|
||||
: id(0)
|
||||
, addr(addr_)
|
||||
, fail_count(0) {}
|
||||
|
@@ -55,8 +55,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
namespace libtorrent { namespace dht
|
||||
{
|
||||
|
||||
using asio::ip::udp;
|
||||
|
||||
//TORRENT_DECLARE_LOG(table);
|
||||
|
||||
typedef std::vector<node_entry> bucket_t;
|
||||
|
@@ -56,7 +56,6 @@ namespace libtorrent { namespace dht
|
||||
|
||||
struct observer;
|
||||
|
||||
using asio::ip::udp;
|
||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||
TORRENT_DECLARE_LOG(rpc);
|
||||
#endif
|
||||
|
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void resend_announce(asio::error_code const& e, std::string msg);
|
||||
void resend_announce(error_code const& e, std::string msg);
|
||||
void on_announce(udp::endpoint const& from, char* buffer
|
||||
, std::size_t bytes_transferred);
|
||||
// void setup_receive();
|
||||
|
@@ -70,12 +70,12 @@ private:
|
||||
|
||||
void update_mapping(int i);
|
||||
void send_map_request(int i);
|
||||
void resend_request(int i, asio::error_code const& e);
|
||||
void on_reply(asio::error_code const& e
|
||||
void resend_request(int i, error_code const& e);
|
||||
void on_reply(error_code const& e
|
||||
, std::size_t bytes_transferred);
|
||||
void try_next_mapping(int i);
|
||||
void update_expiration_timer();
|
||||
void mapping_expired(asio::error_code const& e, int i);
|
||||
void mapping_expired(error_code const& e, int i);
|
||||
|
||||
void disable(char const* message);
|
||||
|
||||
|
@@ -248,7 +248,7 @@ namespace libtorrent
|
||||
// this is called when the connection attempt has succeeded
|
||||
// and the peer_connection is supposed to set m_connecting
|
||||
// to false, and stop monitor writability
|
||||
void on_connection_complete(asio::error_code const& e);
|
||||
void on_connection_complete(error_code const& e);
|
||||
|
||||
// returns true if this connection is still waiting to
|
||||
// finish the connection attempt
|
||||
@@ -449,9 +449,9 @@ namespace libtorrent
|
||||
virtual void on_connected() = 0;
|
||||
virtual void on_tick() {}
|
||||
|
||||
virtual void on_receive(asio::error_code const& error
|
||||
virtual void on_receive(error_code const& error
|
||||
, std::size_t bytes_transferred) = 0;
|
||||
virtual void on_sent(asio::error_code const& error
|
||||
virtual void on_sent(error_code const& error
|
||||
, std::size_t bytes_transferred) = 0;
|
||||
|
||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||
@@ -501,9 +501,9 @@ namespace libtorrent
|
||||
|
||||
// called from the main loop when this connection has any
|
||||
// work to do.
|
||||
void on_send_data(asio::error_code const& error
|
||||
void on_send_data(error_code const& error
|
||||
, std::size_t bytes_transferred);
|
||||
void on_receive_data(asio::error_code const& error
|
||||
void on_receive_data(error_code const& error
|
||||
, std::size_t bytes_transferred);
|
||||
|
||||
// this is the limit on the number of outstanding requests
|
||||
|
@@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <asio/read.hpp>
|
||||
#include <asio/write.hpp>
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
|
||||
|
||||
namespace libtorrent {
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
typedef stream_socket::endpoint_type endpoint_type;
|
||||
typedef stream_socket::protocol_type protocol_type;
|
||||
|
||||
explicit proxy_base(asio::io_service& io_service)
|
||||
explicit proxy_base(io_service& io_service)
|
||||
: m_sock(io_service)
|
||||
, m_resolver(io_service)
|
||||
{}
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
}
|
||||
|
||||
template <class Mutable_Buffers>
|
||||
std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec)
|
||||
std::size_t read_some(Mutable_Buffers const& buffers, error_code& ec)
|
||||
{
|
||||
return m_sock.read_some(buffers, ec);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
#endif
|
||||
|
||||
template <class IO_Control_Command>
|
||||
void io_control(IO_Control_Command& ioc, asio::error_code& ec)
|
||||
void io_control(IO_Control_Command& ioc, error_code& ec)
|
||||
{
|
||||
m_sock.io_control(ioc, ec);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
#endif
|
||||
|
||||
template <class SettableSocketOption>
|
||||
asio::error_code set_option(SettableSocketOption const& opt, asio::error_code& ec)
|
||||
error_code set_option(SettableSocketOption const& opt, error_code& ec)
|
||||
{
|
||||
return m_sock.set_option(opt, ec);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void bind(endpoint_type const& endpoint, asio::error_code& ec)
|
||||
void bind(endpoint_type const& endpoint, error_code& ec)
|
||||
{
|
||||
m_sock.bind(endpoint, ec);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void open(protocol_type const& p, asio::error_code& ec)
|
||||
void open(protocol_type const& p, error_code& ec)
|
||||
{
|
||||
m_sock.open(p, ec);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void close(asio::error_code& ec)
|
||||
void close(error_code& ec)
|
||||
{
|
||||
m_sock.close(ec);
|
||||
m_resolver.cancel();
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
endpoint_type remote_endpoint(asio::error_code& ec) const
|
||||
endpoint_type remote_endpoint(error_code& ec) const
|
||||
{
|
||||
return m_remote_endpoint;
|
||||
}
|
||||
@@ -173,14 +173,14 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
endpoint_type local_endpoint(asio::error_code& ec) const
|
||||
endpoint_type local_endpoint(error_code& ec) const
|
||||
{
|
||||
return m_sock.local_endpoint(ec);
|
||||
}
|
||||
|
||||
asio::io_service& io_service()
|
||||
io_service& get_io_service()
|
||||
{
|
||||
return m_sock.io_service();
|
||||
return m_sock.get_io_service();
|
||||
}
|
||||
|
||||
lowest_layer_type& lowest_layer()
|
||||
|
@@ -45,13 +45,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#define Protocol Protocol_
|
||||
#endif
|
||||
|
||||
#include <asio/ip/tcp.hpp>
|
||||
#include <asio/ip/udp.hpp>
|
||||
#include <asio/io_service.hpp>
|
||||
#include <asio/deadline_timer.hpp>
|
||||
#include <asio/write.hpp>
|
||||
#include <asio/time_traits.hpp>
|
||||
#include <asio/basic_deadline_timer.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <boost/asio/time_traits.hpp>
|
||||
#include <boost/asio/basic_deadline_timer.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
#ifdef __OBJC__
|
||||
#undef Protocol
|
||||
@@ -83,23 +85,27 @@ namespace libtorrent
|
||||
*/
|
||||
// namespace asio = ::asio;
|
||||
|
||||
using asio::ip::tcp;
|
||||
using asio::ip::udp;
|
||||
typedef asio::ip::tcp::socket stream_socket;
|
||||
typedef asio::ip::address address;
|
||||
typedef asio::ip::address_v4 address_v4;
|
||||
typedef asio::ip::address_v6 address_v6;
|
||||
typedef asio::ip::udp::socket datagram_socket;
|
||||
typedef asio::ip::tcp::acceptor socket_acceptor;
|
||||
typedef asio::io_service io_service;
|
||||
using boost::system::error_code;
|
||||
using boost::asio::ip::tcp;
|
||||
using boost::asio::ip::udp;
|
||||
using boost::asio::async_write;
|
||||
using boost::asio::async_read;
|
||||
|
||||
using asio::async_write;
|
||||
typedef boost::asio::ip::tcp::socket stream_socket;
|
||||
typedef boost::asio::ip::address address;
|
||||
typedef boost::asio::ip::address_v4 address_v4;
|
||||
typedef boost::asio::ip::address_v6 address_v6;
|
||||
typedef boost::asio::ip::udp::socket datagram_socket;
|
||||
typedef boost::asio::ip::tcp::acceptor socket_acceptor;
|
||||
typedef boost::asio::io_service io_service;
|
||||
|
||||
namespace asio = boost::asio;
|
||||
|
||||
typedef asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
|
||||
typedef boost::asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
|
||||
|
||||
inline std::ostream& print_address(std::ostream& os, address const& addr)
|
||||
{
|
||||
asio::error_code ec;
|
||||
error_code ec;
|
||||
std::string a = addr.to_string(ec);
|
||||
if (ec) return os;
|
||||
os << a;
|
||||
@@ -109,7 +115,7 @@ namespace libtorrent
|
||||
inline std::ostream& print_endpoint(std::ostream& os, tcp::endpoint const& ep)
|
||||
{
|
||||
address const& addr = ep.address();
|
||||
asio::error_code ec;
|
||||
error_code ec;
|
||||
std::string a = addr.to_string(ec);
|
||||
if (ec) return os;
|
||||
|
||||
@@ -132,7 +138,7 @@ namespace libtorrent
|
||||
}
|
||||
else if (a.is_v6())
|
||||
{
|
||||
asio::ip::address_v6::bytes_type bytes
|
||||
address_v6::bytes_type bytes
|
||||
= a.to_v6().to_bytes();
|
||||
std::copy(bytes.begin(), bytes.end(), out);
|
||||
}
|
||||
@@ -142,18 +148,18 @@ namespace libtorrent
|
||||
address read_v4_address(InIt& in)
|
||||
{
|
||||
unsigned long ip = read_uint32(in);
|
||||
return asio::ip::address_v4(ip);
|
||||
return address_v4(ip);
|
||||
}
|
||||
|
||||
template<class InIt>
|
||||
address read_v6_address(InIt& in)
|
||||
{
|
||||
typedef asio::ip::address_v6::bytes_type bytes_t;
|
||||
typedef address_v6::bytes_type bytes_t;
|
||||
bytes_t bytes;
|
||||
for (bytes_t::iterator i = bytes.begin()
|
||||
, end(bytes.end()); i != end; ++i)
|
||||
*i = read_uint8(in);
|
||||
return asio::ip::address_v6(bytes);
|
||||
return address_v6(bytes);
|
||||
}
|
||||
|
||||
template<class Endpoint, class OutIt>
|
||||
|
@@ -41,8 +41,8 @@ class socks4_stream : public proxy_base
|
||||
{
|
||||
public:
|
||||
|
||||
explicit socks4_stream(asio::io_service& io_service)
|
||||
: proxy_base(io_service)
|
||||
explicit socks4_stream(io_service& io_service_)
|
||||
: proxy_base(io_service_)
|
||||
{}
|
||||
|
||||
void set_username(std::string const& user)
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
m_user = user;
|
||||
}
|
||||
|
||||
typedef boost::function<void(asio::error_code const&)> handler_type;
|
||||
typedef boost::function<void(error_code const&)> handler_type;
|
||||
|
||||
template <class Handler>
|
||||
void async_connect(endpoint_type const& endpoint, Handler const& handler)
|
||||
@@ -74,11 +74,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void name_lookup(asio::error_code const& e, tcp::resolver::iterator i
|
||||
void name_lookup(error_code const& e, tcp::resolver::iterator i
|
||||
, boost::shared_ptr<handler_type> h);
|
||||
void connected(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void connected(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake1(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake2(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
|
||||
// send and receive buffer
|
||||
std::vector<char> m_buffer;
|
||||
|
@@ -41,7 +41,7 @@ class socks5_stream : public proxy_base
|
||||
{
|
||||
public:
|
||||
|
||||
explicit socks5_stream(asio::io_service& io_service)
|
||||
explicit socks5_stream(io_service& io_service)
|
||||
: proxy_base(io_service)
|
||||
{}
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
m_password = password;
|
||||
}
|
||||
|
||||
typedef boost::function<void(asio::error_code const&)> handler_type;
|
||||
typedef boost::function<void(error_code const&)> handler_type;
|
||||
|
||||
template <class Handler>
|
||||
void async_connect(endpoint_type const& endpoint, Handler const& handler)
|
||||
@@ -79,17 +79,17 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void name_lookup(asio::error_code const& e, tcp::resolver::iterator i
|
||||
void name_lookup(error_code const& e, tcp::resolver::iterator i
|
||||
, boost::shared_ptr<handler_type> h);
|
||||
void connected(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake1(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake3(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake4(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void connected(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake1(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake2(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake3(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void handshake4(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void socks_connect(boost::shared_ptr<handler_type> h);
|
||||
void connect1(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void connect2(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void connect3(asio::error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void connect1(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void connect2(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
void connect3(error_code const& e, boost::shared_ptr<handler_type> h);
|
||||
|
||||
// send and receive buffer
|
||||
std::vector<char> m_buffer;
|
||||
|
@@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#define TORRENT_SSL_STREAM_HPP_INCLUDED
|
||||
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include <asio/ssl.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
|
||||
// openssl seems to believe it owns
|
||||
// this name in every single scope
|
||||
@@ -47,7 +47,7 @@ class ssl_stream
|
||||
{
|
||||
public:
|
||||
|
||||
explicit ssl_stream(asio::io_service& io_service)
|
||||
explicit ssl_stream(io_service& io_service)
|
||||
: m_context(io_service, asio::ssl::context::sslv23_client)
|
||||
, m_sock(io_service, m_context)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
typedef typename Stream::protocol_type protocol_type;
|
||||
typedef typename asio::ssl::stream<Stream> sock_type;
|
||||
|
||||
typedef boost::function<void(asio::error_code const&)> handler_type;
|
||||
typedef boost::function<void(error_code const&)> handler_type;
|
||||
|
||||
template <class Handler>
|
||||
void async_connect(endpoint_type const& endpoint, Handler const& handler)
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
// 2. perform SSL client handshake
|
||||
|
||||
// to avoid unnecessary copying of the handler,
|
||||
// store it in a shaed_ptr
|
||||
// store it in a shared_ptr
|
||||
boost::shared_ptr<handler_type> h(new handler_type(handler));
|
||||
|
||||
m_sock.next_layer().async_connect(endpoint
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
}
|
||||
|
||||
template <class Mutable_Buffers>
|
||||
std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec)
|
||||
std::size_t read_some(Mutable_Buffers const& buffers, error_code& ec)
|
||||
{
|
||||
return m_sock.read_some(buffers, ec);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
#endif
|
||||
|
||||
template <class IO_Control_Command>
|
||||
void io_control(IO_Control_Command& ioc, asio::error_code& ec)
|
||||
void io_control(IO_Control_Command& ioc, error_code& ec)
|
||||
{
|
||||
m_sock.next_layer().io_control(ioc, ec);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void bind(endpoint_type const& endpoint, asio::error_code& ec)
|
||||
void bind(endpoint_type const& endpoint, error_code& ec)
|
||||
{
|
||||
m_sock.next_layer().bind(endpoint, ec);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void open(protocol_type const& p, asio::error_code& ec)
|
||||
void open(protocol_type const& p, error_code& ec)
|
||||
{
|
||||
m_sock.next_layer().open(p, ec);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void close(asio::error_code& ec)
|
||||
void close(error_code& ec)
|
||||
{
|
||||
m_sock.next_layer().close(ec);
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
endpoint_type remote_endpoint(asio::error_code& ec) const
|
||||
endpoint_type remote_endpoint(error_code& ec) const
|
||||
{
|
||||
return const_cast<sock_type&>(m_sock).next_layer().remote_endpoint(ec);
|
||||
}
|
||||
@@ -175,14 +175,14 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
endpoint_type local_endpoint(asio::error_code& ec) const
|
||||
endpoint_type local_endpoint(error_code& ec) const
|
||||
{
|
||||
return const_cast<sock_type&>(m_sock).next_layer().local_endpoint(ec);
|
||||
}
|
||||
|
||||
asio::io_service& io_service()
|
||||
io_service& get_io_service()
|
||||
{
|
||||
return m_sock.io_service();
|
||||
return m_sock.get_io_service();
|
||||
}
|
||||
|
||||
lowest_layer_type& lowest_layer()
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void connected(asio::error_code const& e, boost::shared_ptr<handler_type> h)
|
||||
void connected(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||
{
|
||||
if (e)
|
||||
{
|
||||
@@ -209,7 +209,7 @@ private:
|
||||
, boost::bind(&ssl_stream::handshake, this, _1, h));
|
||||
}
|
||||
|
||||
void handshake(asio::error_code const& e, boost::shared_ptr<handler_type> h)
|
||||
void handshake(error_code const& e, boost::shared_ptr<handler_type> h)
|
||||
{
|
||||
(*h)(e);
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ namespace libtorrent
|
||||
|
||||
#else
|
||||
|
||||
#include <asio/time_traits.hpp>
|
||||
#include <boost/asio/time_traits.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace libtorrent
|
||||
}
|
||||
|
||||
// asio time_traits
|
||||
namespace asio
|
||||
namespace boost { namespace asio
|
||||
{
|
||||
template<>
|
||||
struct time_traits<libtorrent::ptime>
|
||||
@@ -171,7 +171,7 @@ namespace asio
|
||||
duration_type d)
|
||||
{ return boost::posix_time::microseconds(libtorrent::total_microseconds(d)); }
|
||||
};
|
||||
}
|
||||
} }
|
||||
|
||||
#if defined(__MACH__)
|
||||
|
||||
|
@@ -461,17 +461,17 @@ namespace libtorrent
|
||||
|
||||
// this is the asio callback that is called when a name
|
||||
// lookup for a PEER is completed.
|
||||
void on_peer_name_lookup(asio::error_code const& e, tcp::resolver::iterator i
|
||||
void on_peer_name_lookup(error_code const& e, tcp::resolver::iterator i
|
||||
, peer_id pid);
|
||||
|
||||
// this is the asio callback that is called when a name
|
||||
// lookup for a WEB SEED is completed.
|
||||
void on_name_lookup(asio::error_code const& e, tcp::resolver::iterator i
|
||||
void on_name_lookup(error_code const& e, tcp::resolver::iterator i
|
||||
, std::string url, tcp::endpoint proxy);
|
||||
|
||||
// this is the asio callback that is called when a name
|
||||
// lookup for a proxy for a web seed is completed.
|
||||
void on_proxy_name_lookup(asio::error_code const& e, tcp::resolver::iterator i
|
||||
void on_proxy_name_lookup(error_code const& e, tcp::resolver::iterator i
|
||||
, std::string url);
|
||||
|
||||
// this is called when the torrent has finished. i.e.
|
||||
@@ -587,7 +587,7 @@ namespace libtorrent
|
||||
|
||||
void try_next_tracker();
|
||||
int prioritize_tracker(int tracker_index);
|
||||
void on_country_lookup(asio::error_code const& error, tcp::resolver::iterator i
|
||||
void on_country_lookup(error_code const& error, tcp::resolver::iterator i
|
||||
, boost::intrusive_ptr<peer_connection> p) const;
|
||||
bool request_bandwidth_from_session(int channel) const;
|
||||
|
||||
@@ -702,7 +702,7 @@ namespace libtorrent
|
||||
deadline_timer m_announce_timer;
|
||||
|
||||
static void on_announce_disp(boost::weak_ptr<torrent> p
|
||||
, asio::error_code const& e);
|
||||
, error_code const& e);
|
||||
|
||||
// this is called once per announce interval
|
||||
void on_announce();
|
||||
|
@@ -160,7 +160,7 @@ namespace libtorrent
|
||||
|
||||
private:
|
||||
|
||||
void timeout_callback(asio::error_code const&);
|
||||
void timeout_callback(error_code const&);
|
||||
|
||||
boost::intrusive_ptr<timeout_handler> self()
|
||||
{ return boost::intrusive_ptr<timeout_handler>(this); }
|
||||
|
@@ -46,16 +46,16 @@ namespace libtorrent
|
||||
class udp_socket
|
||||
{
|
||||
public:
|
||||
typedef boost::function<void(asio::error_code const& ec
|
||||
typedef boost::function<void(error_code const& ec
|
||||
, udp::endpoint const&, char const* buf, int size)> callback_t;
|
||||
|
||||
udp_socket(asio::io_service& ios, callback_t const& c, connection_queue& cc);
|
||||
udp_socket(io_service& ios, callback_t const& c, connection_queue& cc);
|
||||
|
||||
bool is_open() const { return m_ipv4_sock.is_open() || m_ipv6_sock.is_open(); }
|
||||
asio::io_service& get_io_service() { return m_ipv4_sock.get_io_service(); }
|
||||
io_service& get_io_service() { return m_ipv4_sock.get_io_service(); }
|
||||
|
||||
void send(udp::endpoint const& ep, char const* p, int len, asio::error_code& ec);
|
||||
void bind(udp::endpoint const& ep, asio::error_code& ec);
|
||||
void send(udp::endpoint const& ep, char const* p, int len, error_code& ec);
|
||||
void bind(udp::endpoint const& ep, error_code& ec);
|
||||
void bind(int port);
|
||||
void close();
|
||||
int local_port() const { return m_bind_port; }
|
||||
@@ -67,21 +67,21 @@ namespace libtorrent
|
||||
|
||||
callback_t m_callback;
|
||||
|
||||
void on_read(udp::socket* sock, asio::error_code const& e, std::size_t bytes_transferred);
|
||||
void on_name_lookup(asio::error_code const& e, tcp::resolver::iterator i);
|
||||
void on_read(udp::socket* sock, error_code const& e, std::size_t bytes_transferred);
|
||||
void on_name_lookup(error_code const& e, tcp::resolver::iterator i);
|
||||
void on_timeout();
|
||||
void on_connect(int ticket);
|
||||
void on_connected(asio::error_code const& ec);
|
||||
void handshake1(asio::error_code const& e);
|
||||
void handshake2(asio::error_code const& e);
|
||||
void handshake3(asio::error_code const& e);
|
||||
void handshake4(asio::error_code const& e);
|
||||
void on_connected(error_code const& ec);
|
||||
void handshake1(error_code const& e);
|
||||
void handshake2(error_code const& e);
|
||||
void handshake3(error_code const& e);
|
||||
void handshake4(error_code const& e);
|
||||
void socks_forward_udp();
|
||||
void connect1(asio::error_code const& e);
|
||||
void connect2(asio::error_code const& e);
|
||||
void connect1(error_code const& e);
|
||||
void connect2(error_code const& e);
|
||||
|
||||
void wrap(udp::endpoint const& ep, char const* p, int len, asio::error_code& ec);
|
||||
void unwrap(asio::error_code const& e, char const* buf, int size);
|
||||
void wrap(udp::endpoint const& ep, char const* p, int len, error_code& ec);
|
||||
void unwrap(error_code const& e, char const* buf, int size);
|
||||
|
||||
udp::socket m_ipv4_sock;
|
||||
udp::socket m_ipv6_sock;
|
||||
|
@@ -89,10 +89,10 @@ namespace libtorrent
|
||||
boost::intrusive_ptr<udp_tracker_connection> self()
|
||||
{ return boost::intrusive_ptr<udp_tracker_connection>(this); }
|
||||
|
||||
void name_lookup(asio::error_code const& error, udp::resolver::iterator i);
|
||||
void timeout(asio::error_code const& error);
|
||||
void name_lookup(error_code const& error, udp::resolver::iterator i);
|
||||
void timeout(error_code const& error);
|
||||
|
||||
void on_receive(asio::error_code const& e, udp::endpoint const& ep
|
||||
void on_receive(error_code const& e, udp::endpoint const& ep
|
||||
, char const* buf, int size);
|
||||
void on_connect_response(char const* buf, int size);
|
||||
void on_announce_response(char const* buf, int size);
|
||||
|
@@ -93,7 +93,7 @@ private:
|
||||
|
||||
enum { default_lease_time = 3600 };
|
||||
|
||||
void resend_request(asio::error_code const& e);
|
||||
void resend_request(error_code const& e);
|
||||
void on_reply(udp::endpoint const& from, char* buffer
|
||||
, std::size_t bytes_transferred);
|
||||
|
||||
@@ -102,15 +102,15 @@ private:
|
||||
void update_map(rootdevice& d, int i);
|
||||
|
||||
|
||||
void on_upnp_xml(asio::error_code const& e
|
||||
void on_upnp_xml(error_code const& e
|
||||
, libtorrent::http_parser const& p, rootdevice& d);
|
||||
void on_upnp_map_response(asio::error_code const& e
|
||||
void on_upnp_map_response(error_code const& e
|
||||
, libtorrent::http_parser const& p, rootdevice& d
|
||||
, int mapping);
|
||||
void on_upnp_unmap_response(asio::error_code const& e
|
||||
void on_upnp_unmap_response(error_code const& e
|
||||
, libtorrent::http_parser const& p, rootdevice& d
|
||||
, int mapping);
|
||||
void on_expire(asio::error_code const& e);
|
||||
void on_expire(error_code const& e);
|
||||
|
||||
void disable(char const* msg);
|
||||
void return_error(int mapping, int code);
|
||||
@@ -237,7 +237,7 @@ private:
|
||||
// current retry count
|
||||
int m_retry_count;
|
||||
|
||||
asio::io_service& m_io_service;
|
||||
io_service& m_io_service;
|
||||
|
||||
// the udp socket used to send and receive
|
||||
// multicast messages on the network
|
||||
|
@@ -21,7 +21,7 @@
|
||||
# include <boost/type_traits/add_pointer.hpp>
|
||||
# include <boost/noncopyable.hpp>
|
||||
|
||||
#include <asio/io_service.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
# define NETWORK_VARIANT_STREAM_LIMIT 5
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace aux
|
||||
template<class IO_Control_Command>
|
||||
struct io_control_visitor_ec: boost::static_visitor<>
|
||||
{
|
||||
io_control_visitor_ec(IO_Control_Command& ioc, asio::error_code& ec_)
|
||||
io_control_visitor_ec(IO_Control_Command& ioc, error_code& ec_)
|
||||
: ioc(ioc), ec(ec_) {}
|
||||
|
||||
template <class T>
|
||||
@@ -61,7 +61,7 @@ namespace aux
|
||||
{}
|
||||
|
||||
IO_Control_Command& ioc;
|
||||
asio::error_code& ec;
|
||||
error_code& ec;
|
||||
};
|
||||
|
||||
template<class IO_Control_Command>
|
||||
@@ -112,7 +112,7 @@ namespace aux
|
||||
struct bind_visitor_ec
|
||||
: boost::static_visitor<>
|
||||
{
|
||||
bind_visitor_ec(EndpointType const& ep, asio::error_code& ec_)
|
||||
bind_visitor_ec(EndpointType const& ep, error_code& ec_)
|
||||
: endpoint(ep)
|
||||
, ec(ec_)
|
||||
{}
|
||||
@@ -124,7 +124,7 @@ namespace aux
|
||||
void operator()(boost::blank) const {}
|
||||
|
||||
EndpointType const& endpoint;
|
||||
asio::error_code& ec;
|
||||
error_code& ec;
|
||||
};
|
||||
|
||||
template <class EndpointType>
|
||||
@@ -150,7 +150,7 @@ namespace aux
|
||||
struct open_visitor_ec
|
||||
: boost::static_visitor<>
|
||||
{
|
||||
open_visitor_ec(Protocol const& p, asio::error_code& ec_)
|
||||
open_visitor_ec(Protocol const& p, error_code& ec_)
|
||||
: proto(p)
|
||||
, ec(ec_)
|
||||
{}
|
||||
@@ -162,7 +162,7 @@ namespace aux
|
||||
void operator()(boost::blank) const {}
|
||||
|
||||
Protocol const& proto;
|
||||
asio::error_code& ec;
|
||||
error_code& ec;
|
||||
};
|
||||
|
||||
template <class Protocol>
|
||||
@@ -201,7 +201,7 @@ namespace aux
|
||||
struct close_visitor_ec
|
||||
: boost::static_visitor<>
|
||||
{
|
||||
close_visitor_ec(asio::error_code& ec_)
|
||||
close_visitor_ec(error_code& ec_)
|
||||
: ec(ec_)
|
||||
{}
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace aux
|
||||
|
||||
void operator()(boost::blank) const {}
|
||||
|
||||
asio::error_code& ec;
|
||||
error_code& ec;
|
||||
};
|
||||
|
||||
struct close_visitor
|
||||
@@ -230,18 +230,18 @@ namespace aux
|
||||
struct remote_endpoint_visitor_ec
|
||||
: boost::static_visitor<EndpointType>
|
||||
{
|
||||
remote_endpoint_visitor_ec(asio::error_code& ec)
|
||||
: error_code(ec)
|
||||
remote_endpoint_visitor_ec(error_code& ec_)
|
||||
: ec(ec_)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
EndpointType operator()(T const* p) const
|
||||
{ return p->remote_endpoint(error_code); }
|
||||
{ return p->remote_endpoint(ec); }
|
||||
|
||||
EndpointType operator()(boost::blank) const
|
||||
{ return EndpointType(); }
|
||||
|
||||
asio::error_code& error_code;
|
||||
error_code& ec;
|
||||
};
|
||||
|
||||
template <class EndpointType>
|
||||
@@ -270,29 +270,29 @@ namespace aux
|
||||
void operator()(T* p) const
|
||||
{ p->set_option(opt_); }
|
||||
|
||||
void operator()(boost::blank) const {}
|
||||
void operator()(boost::blank) const {}
|
||||
|
||||
SettableSocketOption const& opt_;
|
||||
};
|
||||
|
||||
template <class SettableSocketOption>
|
||||
struct set_option_visitor_ec
|
||||
: boost::static_visitor<asio::error_code>
|
||||
: boost::static_visitor<error_code>
|
||||
{
|
||||
set_option_visitor_ec(SettableSocketOption const& opt, asio::error_code& ec)
|
||||
set_option_visitor_ec(SettableSocketOption const& opt, error_code& ec)
|
||||
: opt_(opt)
|
||||
, ec_(ec)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
asio::error_code operator()(T* p) const
|
||||
error_code operator()(T* p) const
|
||||
{ return p->set_option(opt_, ec_); }
|
||||
|
||||
asio::error_code operator()(boost::blank) const
|
||||
error_code operator()(boost::blank) const
|
||||
{ return ec_; }
|
||||
|
||||
SettableSocketOption const& opt_;
|
||||
asio::error_code& ec_;
|
||||
error_code& ec_;
|
||||
};
|
||||
|
||||
// -------------- local_endpoint -----------
|
||||
@@ -301,14 +301,14 @@ namespace aux
|
||||
struct local_endpoint_visitor_ec
|
||||
: boost::static_visitor<EndpointType>
|
||||
{
|
||||
local_endpoint_visitor_ec(asio::error_code& ec)
|
||||
: error_code(ec)
|
||||
local_endpoint_visitor_ec(error_code& ec_)
|
||||
: ec(ec_)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
EndpointType operator()(T const* p) const
|
||||
{
|
||||
return p->local_endpoint(error_code);
|
||||
return p->local_endpoint(ec);
|
||||
}
|
||||
|
||||
EndpointType operator()(boost::blank) const
|
||||
@@ -316,7 +316,7 @@ namespace aux
|
||||
return EndpointType();
|
||||
}
|
||||
|
||||
asio::error_code& error_code;
|
||||
error_code& ec;
|
||||
};
|
||||
|
||||
template <class EndpointType>
|
||||
@@ -372,7 +372,7 @@ namespace aux
|
||||
std::size_t operator()(T* p) const
|
||||
{ return p->read_some(buffers); }
|
||||
|
||||
std::size_t operator()(boost::blank) const
|
||||
std::size_t operator()(boost::blank) const
|
||||
{ return 0; }
|
||||
|
||||
Mutable_Buffers const& buffers;
|
||||
@@ -382,7 +382,7 @@ namespace aux
|
||||
struct read_some_visitor_ec
|
||||
: boost::static_visitor<std::size_t>
|
||||
{
|
||||
read_some_visitor_ec(Mutable_Buffers const& buffers, asio::error_code& ec_)
|
||||
read_some_visitor_ec(Mutable_Buffers const& buffers, error_code& ec_)
|
||||
: buffers(buffers)
|
||||
, ec(ec_)
|
||||
{}
|
||||
@@ -391,11 +391,11 @@ namespace aux
|
||||
std::size_t operator()(T* p) const
|
||||
{ return p->read_some(buffers, ec); }
|
||||
|
||||
std::size_t operator()(boost::blank) const
|
||||
std::size_t operator()(boost::blank) const
|
||||
{ return 0; }
|
||||
|
||||
Mutable_Buffers const& buffers;
|
||||
asio::error_code& ec;
|
||||
error_code& ec;
|
||||
};
|
||||
|
||||
// -------------- async_write_some -----------
|
||||
@@ -427,7 +427,7 @@ namespace aux
|
||||
struct in_avail_visitor_ec
|
||||
: boost::static_visitor<std::size_t>
|
||||
{
|
||||
in_avail_visitor_ec(asio::error_code& ec_)
|
||||
in_avail_visitor_ec(error_code& ec_)
|
||||
: ec(ec_)
|
||||
{}
|
||||
|
||||
@@ -442,7 +442,7 @@ namespace aux
|
||||
return 0;
|
||||
}
|
||||
|
||||
asio::error_code& ec;
|
||||
error_code& ec;
|
||||
};
|
||||
|
||||
struct in_avail_visitor
|
||||
@@ -524,11 +524,11 @@ public:
|
||||
typedef typename S0::endpoint_type endpoint_type;
|
||||
typedef typename S0::protocol_type protocol_type;
|
||||
|
||||
explicit variant_stream(asio::io_service& ios)
|
||||
explicit variant_stream(io_service& ios)
|
||||
: m_io_service(ios), m_variant(boost::blank()) {}
|
||||
|
||||
template <class S>
|
||||
void instantiate(asio::io_service& ios)
|
||||
void instantiate(io_service& ios)
|
||||
{
|
||||
TORRENT_ASSERT(&ios == &m_io_service);
|
||||
std::auto_ptr<S> owned(new S(ios));
|
||||
@@ -540,7 +540,7 @@ public:
|
||||
template <class S>
|
||||
S& get()
|
||||
{
|
||||
return *boost::get<S*>(m_variant);
|
||||
return *boost::get<S*>(m_variant);
|
||||
}
|
||||
|
||||
bool instantiated() const
|
||||
@@ -554,7 +554,7 @@ public:
|
||||
}
|
||||
|
||||
template <class Mutable_Buffers>
|
||||
std::size_t read_some(Mutable_Buffers const& buffers, asio::error_code& ec)
|
||||
std::size_t read_some(Mutable_Buffers const& buffers, error_code& ec)
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
@@ -612,7 +612,7 @@ public:
|
||||
}
|
||||
|
||||
template <class IO_Control_Command>
|
||||
void io_control(IO_Control_Command& ioc, asio::error_code& ec)
|
||||
void io_control(IO_Control_Command& ioc, error_code& ec)
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
@@ -627,7 +627,7 @@ public:
|
||||
boost::apply_visitor(aux::bind_visitor<endpoint_type>(endpoint), m_variant);
|
||||
}
|
||||
|
||||
void bind(endpoint_type const& endpoint, asio::error_code& ec)
|
||||
void bind(endpoint_type const& endpoint, error_code& ec)
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
@@ -641,7 +641,7 @@ public:
|
||||
boost::apply_visitor(aux::open_visitor<protocol_type>(p), m_variant);
|
||||
}
|
||||
|
||||
void open(protocol_type const& p, asio::error_code& ec)
|
||||
void open(protocol_type const& p, error_code& ec)
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(
|
||||
@@ -660,7 +660,7 @@ public:
|
||||
boost::apply_visitor(aux::close_visitor(), m_variant);
|
||||
}
|
||||
|
||||
void close(asio::error_code& ec)
|
||||
void close(error_code& ec)
|
||||
{
|
||||
if (!instantiated()) return;
|
||||
boost::apply_visitor(
|
||||
@@ -674,7 +674,7 @@ public:
|
||||
return boost::apply_visitor(aux::in_avail_visitor(), m_variant);
|
||||
}
|
||||
|
||||
std::size_t in_avail(asio::error_code& ec) const
|
||||
std::size_t in_avail(error_code& ec) const
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
@@ -688,7 +688,7 @@ public:
|
||||
return boost::apply_visitor(aux::remote_endpoint_visitor<endpoint_type>(), m_variant);
|
||||
}
|
||||
|
||||
endpoint_type remote_endpoint(asio::error_code& ec) const
|
||||
endpoint_type remote_endpoint(error_code& ec) const
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
@@ -705,20 +705,20 @@ public:
|
||||
}
|
||||
|
||||
template <class SettableSocketOption>
|
||||
asio::error_code set_option(SettableSocketOption const& opt, asio::error_code& ec)
|
||||
error_code set_option(SettableSocketOption const& opt, error_code& ec)
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(aux::set_option_visitor_ec<SettableSocketOption>(opt, ec)
|
||||
, m_variant);
|
||||
}
|
||||
|
||||
|
||||
endpoint_type local_endpoint() const
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(aux::local_endpoint_visitor<endpoint_type>(), m_variant);
|
||||
}
|
||||
|
||||
endpoint_type local_endpoint(asio::error_code& ec) const
|
||||
endpoint_type local_endpoint(error_code& ec) const
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(
|
||||
@@ -726,7 +726,7 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
asio::io_service& get_io_service()
|
||||
io_service& get_io_service()
|
||||
{
|
||||
return m_io_service;
|
||||
}
|
||||
@@ -740,7 +740,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
asio::io_service& m_io_service;
|
||||
io_service& m_io_service;
|
||||
variant_type m_variant;
|
||||
};
|
||||
|
||||
|
@@ -102,9 +102,9 @@ namespace libtorrent
|
||||
|
||||
// called from the main loop when this connection has any
|
||||
// work to do.
|
||||
void on_sent(asio::error_code const& error
|
||||
void on_sent(error_code const& error
|
||||
, std::size_t bytes_transferred);
|
||||
void on_receive(asio::error_code const& error
|
||||
void on_receive(error_code const& error
|
||||
, std::size_t bytes_transferred);
|
||||
|
||||
std::string const& url() const { return m_url; }
|
||||
|
Reference in New Issue
Block a user