Async Comm
A library for asynchronous serial communication
|
Asynchronous communication class for a TCP client. More...
#include <tcp_client.h>
Public Member Functions | |
TCPClient (std::string host=DEFAULT_HOST, uint16_t port=DEFAULT_PORT, MessageHandler &message_handler=default_message_handler_) | |
Connect to a TCP socket as a client. More... | |
![]() | |
Comm (MessageHandler &message_handler=default_message_handler_) | |
Set up asynchronous communication base class. More... | |
bool | init () |
Initializes and opens the port. More... | |
void | close () |
Closes the port. | |
void | send_bytes (const uint8_t *src, size_t len) |
Send bytes from a buffer over the port. More... | |
void | send_byte (uint8_t data) |
Send a single byte over 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 | register_listener (CommListener &listener) |
Register a listener for when bytes are received on the port. More... | |
Additional Inherited Members | |
![]() | |
MessageHandler & | message_handler_ |
boost::asio::io_service | io_service_ |
![]() | |
static constexpr size_t | READ_BUFFER_SIZE = 1024 |
static constexpr size_t | WRITE_BUFFER_SIZE = 1024 |
static DefaultMessageHandler | default_message_handler_ |
Asynchronous communication class for a TCP client.
Definition at line 56 of file tcp_client.h.
async_comm::TCPClient::TCPClient | ( | std::string | host = DEFAULT_HOST , |
uint16_t | port = DEFAULT_PORT , |
||
MessageHandler & | message_handler = default_message_handler_ |
||
) |
Connect to a TCP socket as a client.
host | The host where the TCP server is running |
port | The port on which the TCP server is listening |
message_handler | Custom message handler, or omit for default handler |
Definition at line 47 of file tcp_client.cpp.