View on GitHub

Thrift Asio

Asynchronous client and server for apache thrift implemented via boost::asio

Download this project as a .zip file Download this project as a tar.gz file
betabugs::networking::thrift_asio_client_transport Class Reference

#include <thrift_asio_client_transport.hpp>

Inheritance diagram for betabugs::networking::thrift_asio_client_transport:
betabugs::networking::thrift_asio_transport

Public Member Functions

 thrift_asio_client_transport (boost::asio::io_service &io_service, const std::string &host_name, const std::string &service_name, event_handlers *event_handlers)
 creates a thrift_asio_client_transport and tries to connect to host_name:service_name More...
 
virtual void open () override
 
void connect_to (const std::string &host_name, const std::string &service_name)
 close the current connection and connect to host_name::service_name
 
- Public Member Functions inherited from betabugs::networking::thrift_asio_transport
 thrift_asio_transport (socket_ptr socket, event_handlers *event_handlers)
 creates a thrift_asio_transport from a socket_ptr
 
uint32_t read (uint8_t *buf, uint32_t len)
 Attempt to read up to the specified number of bytes into the string. More...
 
size_t available_bytes () const
 the number of bytes, that have been received on not yet read()
 
void write (const uint8_t *buf, uint32_t len)
 
virtual bool isOpen () override
 return true unless an error occured or the transport was closed
 
bool isClosed ()
 Checks wether this transport is closed. More...
 
virtual bool peek () override
 return true, if there is data available to be processed
 
virtual void close () override
 closes the transport
 
virtual const std::string getOrigin () override
 

Additional Inherited Members

- Public Types inherited from betabugs::networking::thrift_asio_transport
typedef std::shared_ptr
< boost::asio::ip::tcp::socket > 
socket_ptr
 a shared_ptr to a tcp socket
 
- Protected Types inherited from betabugs::networking::thrift_asio_transport
enum  State { CLOSED, CONNECTING, RESOLVING, OPEN }
 enum to represent the state-machine of the connection More...
 
- Protected Attributes inherited from betabugs::networking::thrift_asio_transport
State state_ = CLOSED
 the state of this transport
 
socket_ptr socket_
 the underlying socket
 
event_handlersevent_handlers_
 handles events like on_error, etc.
 

Detailed Description

In contrast to thrift_asio_transport, this class does name resolution and connects to the endpoint.

Constructor & Destructor Documentation

betabugs::networking::thrift_asio_client_transport::thrift_asio_client_transport ( boost::asio::io_service &  io_service,
const std::string &  host_name,
const std::string &  service_name,
event_handlers event_handlers 
)
inline

creates a thrift_asio_client_transport and tries to connect to host_name:service_name

Parameters
io_serviceio_service to use
host_namename of the host to connect to
service_namei.e. port
event_handlersthe event handlers to use

Member Function Documentation

virtual void betabugs::networking::thrift_asio_client_transport::open ( )
inlineoverridevirtual

tries to resolve host_name:server_name and opens the transport for communication.

In contrast to apache::thrift::TTransport, this does not block and the isOpen method will return false until the connection is established.

Reimplemented from betabugs::networking::thrift_asio_transport.


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