$darkmode
cloe::utility::TcpTransceiver Class Reference

#include <tcp_transceiver.hpp>

Inheritance diagram for cloe::utility::TcpTransceiver:

Public Member Functions

 TcpTransceiver (const std::string &host, uint16_t port)
 
void tcp_connect (const std::string &host, uint16_t port)
 
bool tcp_is_connected () const
 
bool tcp_is_ok () const
 
void tcp_disconnect ()
 
uint16_t tcp_port () const
 
const std::string & tcp_host () const
 
std::string tcp_endpoint () const
 

Protected Member Functions

std::streamsize tcp_available_data () const
 
template<typename M >
void tcp_send (M *msg, size_t sz)
 

Protected Attributes

boost::asio::ip::tcp::iostream tcp_stream_
 
bool tcp_connected_ {false}
 
std::string tcp_host_ {}
 
uint16_t tcp_port_ {}
 

Detailed Description

TcpTransceiver is a TCP transceiver, which contains common methods for creating a connection, sending, receiving, and tearing it down again.

Member Function Documentation

◆ tcp_available_data()

std::streamsize cloe::utility::TcpTransceiver::tcp_available_data ( ) const
inlineprotected

Returns the amount of available data in the buffer and on the socket.

Here is the caller graph for this function:

◆ tcp_connect()

void cloe::utility::TcpTransceiver::tcp_connect ( const std::string &  host,
uint16_t  port 
)
inline

Attempts to set up a TCP connection to this host and port.

  • If it cannot connect it throws a std::runtime_error.

◆ tcp_disconnect()

void cloe::utility::TcpTransceiver::tcp_disconnect ( )
inline

Close the underlying stream and mark this object as disconnected.

It is not necessary to call this before destruction.

◆ tcp_is_connected()

bool cloe::utility::TcpTransceiver::tcp_is_connected ( ) const
inline

Returns true if this object should be connected.

  • It does not take errors into account.

◆ tcp_is_ok()

bool cloe::utility::TcpTransceiver::tcp_is_ok ( ) const
inline

Returns true if the underlying TCP stream reports ok.

This only makes sense if tcp_is_connected() returns true.


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