The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
network_asio::connection Class Reference

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_
 

Detailed Description

A class that represents a TCP/IP connection.

Definition at line 45 of file network_asio.hpp.

Member Typedef Documentation

typedef boost::asio::ip::tcp::resolver network_asio::connection::resolver
private

Definition at line 48 of file network_asio.hpp.

typedef boost::asio::ip::tcp::socket network_asio::connection::socket
private

Definition at line 51 of file network_asio.hpp.

Constructor & Destructor Documentation

network_asio::connection::connection ( const std::string host,
const std::string service 
)

Constructor.

Parameters
hostName of the host to connect to
serviceService identifier such as "80" or "http"

Definition at line 34 of file network_asio.cpp.

References handle_resolve(), LOG_NW, and resolver_.

Member Function Documentation

std::size_t network_asio::connection::bytes_read ( ) const
inline

Definition at line 147 of file network_asio.hpp.

References bytes_read_.

Referenced by read_addon_connection_data::current().

std::size_t network_asio::connection::bytes_to_read ( ) const
inline

Definition at line 143 of file network_asio.hpp.

References bytes_to_read_.

Referenced by read_addon_connection_data::total().

std::size_t network_asio::connection::bytes_to_write ( ) const
inline

Definition at line 135 of file network_asio.hpp.

References bytes_to_write_.

Referenced by write_addon_connection_data::total().

std::size_t network_asio::connection::bytes_written ( ) const
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().

void network_asio::connection::connect ( resolver::iterator  iterator)
private

Definition at line 66 of file network_asio.cpp.

References handle_connect(), LOG_NW, and socket_.

Referenced by handle_connect(), and handle_resolve().

bool network_asio::connection::done ( ) const
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().

void network_asio::connection::handle_connect ( const boost::system::error_code &  ec,
resolver::iterator  iterator 
)
private

Definition at line 74 of file network_asio.cpp.

References connect(), ERR_NW, handshake(), LOG_NW, socket_, and WRN_NW.

Referenced by connect().

void network_asio::connection::handle_handshake ( const boost::system::error_code &  ec)
private

Definition at line 108 of file network_asio.cpp.

References done_.

Referenced by handshake().

void network_asio::connection::handle_read ( const boost::system::error_code &  ec,
std::size_t  bytes_transferred,
config response 
)
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().

void network_asio::connection::handle_resolve ( const boost::system::error_code &  ec,
resolver::iterator  iterator 
)
private

Definition at line 55 of file network_asio.cpp.

References connect().

Referenced by connection().

void network_asio::connection::handle_write ( const boost::system::error_code &  ec,
std::size_t  bytes_transferred 
)
private

Definition at line 166 of file network_asio.cpp.

References DBG_NW, and write_buf_.

Referenced by handshake(), and transfer().

void network_asio::connection::handshake ( )
private

Definition at line 95 of file network_asio.cpp.

References handle_handshake(), handle_write(), handshake_response_, and socket_.

Referenced by handle_connect().

std::size_t network_asio::connection::is_read_complete ( const boost::system::error_code &  error,
std::size_t  bytes_transferred 
)
private

Definition at line 177 of file network_asio.cpp.

References bytes_read_, bytes_to_read_, num, and read_buf_.

Referenced by transfer().

std::size_t network_asio::connection::is_write_complete ( const boost::system::error_code &  error,
std::size_t  bytes_transferred 
)
private

Definition at line 151 of file network_asio.cpp.

References bytes_to_write_, and bytes_written_.

Referenced by transfer().

std::size_t network_asio::connection::poll ( )
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().

void network_asio::connection::run ( )
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.

void network_asio::connection::transfer ( const config request,
config response 
)

Member Data Documentation

char network_asio::connection::binary[4]

Definition at line 74 of file network_asio.hpp.

std::size_t network_asio::connection::bytes_read_
private

Definition at line 99 of file network_asio.hpp.

Referenced by bytes_read(), and is_read_complete().

std::size_t network_asio::connection::bytes_to_read_
private

Definition at line 98 of file network_asio.hpp.

Referenced by bytes_to_read(), handle_read(), and is_read_complete().

std::size_t network_asio::connection::bytes_to_write_
private

Definition at line 96 of file network_asio.hpp.

Referenced by bytes_to_write(), handle_read(), is_write_complete(), and transfer().

std::size_t network_asio::connection::bytes_written_
private

Definition at line 97 of file network_asio.hpp.

Referenced by bytes_written(), is_write_complete(), and transfer().

bool network_asio::connection::done_
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().

boost::asio::io_service network_asio::connection::io_service_
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().

boost::uint32_t network_asio::connection::payload_size_
private

Definition at line 95 of file network_asio.hpp.

Referenced by transfer().

boost::asio::streambuf network_asio::connection::read_buf_
private

Definition at line 57 of file network_asio.hpp.

Referenced by handle_read(), is_read_complete(), and transfer().

resolver network_asio::connection::resolver_
private

Definition at line 49 of file network_asio.hpp.

Referenced by connection().

socket network_asio::connection::socket_
private

Definition at line 52 of file network_asio.hpp.

Referenced by cancel(), connect(), handle_connect(), handshake(), and transfer().

boost::asio::streambuf network_asio::connection::write_buf_
private

Definition at line 56 of file network_asio.hpp.

Referenced by handle_write(), and transfer().


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