Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
async_comm::TCPClient Class Reference

Asynchronous communication class for a TCP client. More...

#include <tcp_client.h>

Inheritance diagram for async_comm::TCPClient:
Inheritance graph
[legend]

Public Member Functions

 TCPClient (std::string host=DEFAULT_HOST, uint16_t port=DEFAULT_PORT)
 Connect to a TCP socket as a client. More...
 
 ~TCPClient ()
 
- Public Member Functions inherited from async_comm::Comm
void close ()
 Closes the port. More...
 
 Comm ()
 
bool init ()
 Initializes and opens the port. More...
 
void register_receive_callback (std::function< void(const uint8_t *, size_t)> fun)
 Register a callback function for when bytes are received on the port. More...
 
void send_byte (uint8_t data)
 Send a single byte over the port. More...
 
void send_bytes (const uint8_t *src, size_t len)
 Send bytes from a buffer over the port. More...
 
virtual ~Comm ()
 

Private Member Functions

void do_async_read (const boost::asio::mutable_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override
 
void do_async_write (const boost::asio::const_buffers_1 &buffer, boost::function< void(const boost::system::error_code &, size_t)> handler) override
 
void do_close () override
 
bool do_init () override
 
bool is_open () override
 

Private Attributes

boost::asio::ip::tcp::endpoint endpoint_
 
std::string host_
 
uint16_t port_
 
boost::asio::ip::tcp::socket socket_
 

Static Private Attributes

static constexpr auto DEFAULT_HOST = "localhost"
 
static constexpr uint16_t DEFAULT_PORT = 16140
 

Additional Inherited Members

- Protected Attributes inherited from async_comm::Comm
boost::asio::io_service io_service_
 
- Static Protected Attributes inherited from async_comm::Comm
static constexpr size_t READ_BUFFER_SIZE = 1024
 
static constexpr size_t WRITE_BUFFER_SIZE = 1024
 

Detailed Description

Asynchronous communication class for a TCP client.

Definition at line 55 of file tcp_client.h.

Constructor & Destructor Documentation

async_comm::TCPClient::TCPClient ( std::string  host = DEFAULT_HOST,
uint16_t  port = DEFAULT_PORT 
)

Connect to a TCP socket as a client.

Parameters
hostThe host where the TCP server is running
portThe port on which the TCP server is listening

Definition at line 47 of file tcp_client.cpp.

async_comm::TCPClient::~TCPClient ( )

Definition at line 55 of file tcp_client.cpp.

Member Function Documentation

void async_comm::TCPClient::do_async_read ( const boost::asio::mutable_buffers_1 &  buffer,
boost::function< void(const boost::system::error_code &, size_t)>  handler 
)
overrideprivatevirtual

Implements async_comm::Comm.

Definition at line 95 of file tcp_client.cpp.

void async_comm::TCPClient::do_async_write ( const boost::asio::const_buffers_1 &  buffer,
boost::function< void(const boost::system::error_code &, size_t)>  handler 
)
overrideprivatevirtual

Implements async_comm::Comm.

Definition at line 101 of file tcp_client.cpp.

void async_comm::TCPClient::do_close ( )
overrideprivatevirtual

Implements async_comm::Comm.

Definition at line 90 of file tcp_client.cpp.

bool async_comm::TCPClient::do_init ( )
overrideprivatevirtual

Implements async_comm::Comm.

Definition at line 65 of file tcp_client.cpp.

bool async_comm::TCPClient::is_open ( )
overrideprivatevirtual

Implements async_comm::Comm.

Definition at line 60 of file tcp_client.cpp.

Member Data Documentation

constexpr auto async_comm::TCPClient::DEFAULT_HOST = "localhost"
staticprivate

Definition at line 67 of file tcp_client.h.

constexpr uint16_t async_comm::TCPClient::DEFAULT_PORT = 16140
staticprivate

Definition at line 68 of file tcp_client.h.

boost::asio::ip::tcp::endpoint async_comm::TCPClient::endpoint_
private

Definition at line 82 of file tcp_client.h.

std::string async_comm::TCPClient::host_
private

Definition at line 78 of file tcp_client.h.

uint16_t async_comm::TCPClient::port_
private

Definition at line 79 of file tcp_client.h.

boost::asio::ip::tcp::socket async_comm::TCPClient::socket_
private

Definition at line 81 of file tcp_client.h.


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


async_comm
Author(s):
autogenerated on Thu May 16 2019 03:03:47