A class that represents a TCP/IP connection. More...
#include <network_asio.hpp>
Public Member Functions | |
connection (const std::string &host, const std::string &service) | |
Constructor. More... | |
void | transfer (const config &request, config &response) |
std::size_t | poll () |
Handle all pending asynchonous events and return. More... | |
void | run () |
Run asio's event loop. More... | |
void | cancel () |
bool | done () const |
True if connected and no high-level operation is in progress. More... | |
std::size_t | bytes_to_write () const |
std::size_t | bytes_written () const |
std::size_t | bytes_to_read () const |
std::size_t | bytes_read () const |
Private Types | |
typedef boost::asio::ip::tcp::resolver | resolver |
typedef boost::asio::ip::tcp::socket | socket |
Private Member Functions | |
void | handle_resolve (const boost::system::error_code &ec, resolver::iterator iterator) |
void | connect (resolver::iterator iterator) |
void | handle_connect (const boost::system::error_code &ec, resolver::iterator iterator) |
void | handshake () |
void | handle_handshake (const boost::system::error_code &ec) |
std::size_t | is_write_complete (const boost::system::error_code &error, std::size_t bytes_transferred) |
void | handle_write (const boost::system::error_code &ec, std::size_t bytes_transferred) |
std::size_t | is_read_complete (const boost::system::error_code &error, std::size_t bytes_transferred) |
void | handle_read (const boost::system::error_code &ec, std::size_t bytes_transferred, config &response) |
Private Attributes | |
boost::asio::io_service | io_service_ |
resolver | resolver_ |
socket | socket_ |
bool | done_ |
boost::asio::streambuf | write_buf_ |
boost::asio::streambuf | read_buf_ |
union { | |
char binary [4] | |
boost::uint32_t num | |
} | handshake_response_ |
boost::uint32_t | payload_size_ |
std::size_t | bytes_to_write_ |
std::size_t | bytes_written_ |
std::size_t | bytes_to_read_ |
std::size_t | bytes_read_ |
A class that represents a TCP/IP connection.
Definition at line 45 of file network_asio.hpp.
|
private |
Definition at line 48 of file network_asio.hpp.
|
private |
Definition at line 51 of file network_asio.hpp.
network_asio::connection::connection | ( | const std::string & | host, |
const std::string & | service | ||
) |
Constructor.
host | Name of the host to connect to |
service | Service identifier such as "80" or "http" |
Definition at line 34 of file network_asio.cpp.
References handle_resolve(), LOG_NW, and resolver_.
|
inline |
Definition at line 147 of file network_asio.hpp.
References bytes_read_.
Referenced by read_addon_connection_data::current().
|
inline |
Definition at line 143 of file network_asio.hpp.
References bytes_to_read_.
Referenced by read_addon_connection_data::total().
|
inline |
Definition at line 135 of file network_asio.hpp.
References bytes_to_write_.
Referenced by write_addon_connection_data::total().
|
inline |
Definition at line 139 of file network_asio.hpp.
References bytes_written_.
Referenced by write_addon_connection_data::current().
void network_asio::connection::cancel | ( | ) |
Definition at line 140 of file network_asio.cpp.
References socket_, and WRN_NW.
Referenced by read_addon_connection_data::cancel(), and write_addon_connection_data::cancel().
|
private |
Definition at line 66 of file network_asio.cpp.
References handle_connect(), LOG_NW, and socket_.
Referenced by handle_connect(), and handle_resolve().
|
inline |
True if connected and no high-level operation is in progress.
Definition at line 133 of file network_asio.hpp.
References done_.
Referenced by read_addon_connection_data::finished(), and write_addon_connection_data::finished().
|
private |
Definition at line 74 of file network_asio.cpp.
References connect(), ERR_NW, handshake(), LOG_NW, socket_, and WRN_NW.
Referenced by connect().
|
private |
|
private |
Definition at line 206 of file network_asio.cpp.
References bytes_to_read_, bytes_to_write_, DBG_NW, done_, read_buf_, and read_gz().
Referenced by transfer().
|
private |
|
private |
Definition at line 166 of file network_asio.cpp.
References DBG_NW, and write_buf_.
Referenced by handshake(), and transfer().
|
private |
Definition at line 95 of file network_asio.cpp.
References handle_handshake(), handle_write(), handshake_response_, and socket_.
Referenced by handle_connect().
|
private |
Definition at line 177 of file network_asio.cpp.
References bytes_read_, bytes_to_read_, num, and read_buf_.
Referenced by transfer().
|
private |
Definition at line 151 of file network_asio.cpp.
References bytes_to_write_, and bytes_written_.
Referenced by transfer().
|
inline |
Handle all pending asynchonous events and return.
Definition at line 113 of file network_asio.hpp.
References lg::err(), and error().
Referenced by read_addon_connection_data::poll(), and write_addon_connection_data::poll().
|
inline |
Run asio's event loop.
Handle asynchronous events blocking until all asynchronous operations have finished
Definition at line 128 of file network_asio.hpp.
Definition at line 117 of file network_asio.cpp.
References bytes_to_write_, bytes_written_, done_, handle_read(), handle_write(), io_service_, is_read_complete(), is_write_complete(), payload_size_, read_buf_, socket_, write_buf_, and write_gz().
Referenced by addons_client::send_request().
char network_asio::connection::binary[4] |
Definition at line 74 of file network_asio.hpp.
|
private |
Definition at line 99 of file network_asio.hpp.
Referenced by bytes_read(), and is_read_complete().
|
private |
Definition at line 98 of file network_asio.hpp.
Referenced by bytes_to_read(), handle_read(), and is_read_complete().
|
private |
Definition at line 96 of file network_asio.hpp.
Referenced by bytes_to_write(), handle_read(), is_write_complete(), and transfer().
|
private |
Definition at line 97 of file network_asio.hpp.
Referenced by bytes_written(), is_write_complete(), and transfer().
|
private |
Definition at line 54 of file network_asio.hpp.
Referenced by done(), handle_handshake(), handle_read(), and transfer().
union { ... } network_asio::connection::handshake_response_ |
Referenced by handshake().
|
private |
Definition at line 47 of file network_asio.hpp.
Referenced by transfer().
boost::uint32_t network_asio::connection::num |
Definition at line 75 of file network_asio.hpp.
Referenced by is_read_complete().
|
private |
Definition at line 95 of file network_asio.hpp.
Referenced by transfer().
|
private |
Definition at line 57 of file network_asio.hpp.
Referenced by handle_read(), is_read_complete(), and transfer().
|
private |
Definition at line 49 of file network_asio.hpp.
Referenced by connection().
|
private |
Definition at line 52 of file network_asio.hpp.
Referenced by cancel(), connect(), handle_connect(), handshake(), and transfer().
|
private |
Definition at line 56 of file network_asio.hpp.
Referenced by handle_write(), and transfer().