Async Comm
A library for asynchronous serial communication
Public Member Functions | List of all members
async_comm::UDP Class Reference

Asynchronous communication class for a UDP socket. More...

#include <udp.h>

Inheritance diagram for async_comm::UDP:
Inheritance graph
Collaboration diagram for async_comm::UDP:
Collaboration graph

Public Member Functions

 UDP (std::string bind_host=DEFAULT_BIND_HOST, uint16_t bind_port=DEFAULT_BIND_PORT, std::string remote_host=DEFAULT_REMOTE_HOST, uint16_t remote_port=DEFAULT_REMOTE_PORT, MessageHandler &message_handler=default_message_handler_)
 Bind a UDP socket. More...
- Public Member Functions inherited from async_comm::Comm
 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

- 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
static DefaultMessageHandler default_message_handler_

Detailed Description

Asynchronous communication class for a UDP socket.

Definition at line 56 of file udp.h.

Constructor & Destructor Documentation

◆ UDP()

async_comm::UDP::UDP ( std::string  bind_host = DEFAULT_BIND_HOST,
uint16_t  bind_port = DEFAULT_BIND_PORT,
std::string  remote_host = DEFAULT_REMOTE_HOST,
uint16_t  remote_port = DEFAULT_REMOTE_PORT,
MessageHandler message_handler = default_message_handler_ 

Bind a UDP socket.

bind_hostThe bind host where this application is listening (usually "localhost")
bind_portThe bind port where this application is listening
remote_hostThe remote host to communicate with
remote_portThe port on the remote host
message_handlerCustom message handler, or omit for default handler

Definition at line 48 of file udp.cpp.

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