7#include "sockpp/udp_socket.h"
8#include "sockpp/version.h"
39 bool begin(
const std::string& ipaddr,
unsigned short port);
49 bool begin(
const std::string& ipaddr,
unsigned short port,
unsigned int header,
unsigned int terminator);
60 bool begin(
const std::string& ipaddr,
unsigned short port,
unsigned int header,
unsigned int terminator,
unsigned int timeout);
69 bool read(
unsigned char* packetPtr,
unsigned int size);
78 bool write(
unsigned char* packetPtr,
unsigned int size);
111 bool setIP(
const std::string& ipaddr);
173 static constexpr unsigned int HEADER = 0xFF812345;
181 static constexpr unsigned int MASK = 0xFF;
191 bool init(
const std::string& ipaddr,
unsigned short port,
unsigned int timeout);
A class for host communication via UDP protocol using the broadcast IP.
Definition: HostPortUDP.h:20
static constexpr unsigned int TIMEOUT
Default timeout.
Definition: HostPortUDP.h:175
int _enable
Definition: HostPortUDP.h:188
static constexpr unsigned int MAX_PACKET_SIZE
Maximum packet size in bytes.
Definition: HostPortUDP.h:176
bool setTimeout(unsigned int timeout)
Set the timeout.
unsigned int getHeader(void)
Get the header.
bool init(const std::string &ipaddr, unsigned short port, unsigned int timeout)
Private initialization function.
static constexpr unsigned int HEADER
Default header.
Definition: HostPortUDP.h:173
unsigned int _timeout
Timeout.
Definition: HostPortUDP.h:187
bool flush(void)
Flush the port.
unsigned int _terminator
Terminator bytes.
Definition: HostPortUDP.h:185
HostPortUDP()
Constructor.
bool setIP(const std::string &ipaddr)
Set the IP address.
unsigned int _port
Socket port.
Definition: HostPortUDP.h:183
unsigned int getTimeout(void)
Get the timeout.
static constexpr unsigned int TERMINATOR
Default terminator.
Definition: HostPortUDP.h:174
static constexpr unsigned int MASK
Mask for parsing.
Definition: HostPortUDP.h:181
std::string getIP(void)
Get the IP address.
sockpp::socket_initializer sockInit
Definition: HostPortUDP.h:180
bool setTerminator(unsigned int terminator)
Set the terminator.
unsigned int _header
Header bytes.
Definition: HostPortUDP.h:186
bool read(unsigned char *packetPtr, unsigned int size)
Read data buffer.
unsigned short getPort(void)
Get the serial port.
~HostPortUDP()
Desctructor.
bool write(unsigned char *packetPtr, unsigned int size)
Write data buffer.
unsigned int getTerminator(void)
Get the terminator.
std::string _ip
IP address.
Definition: HostPortUDP.h:184
bool isInit(void)
Check if host port is open.
bool setPort(unsigned short port)
Set the serial port.
bool begin(const std::string &ipaddr, unsigned short port, unsigned int header, unsigned int terminator)
Begin the host port.
bool _isFirstRead
True if firt packer read.
Definition: HostPortUDP.h:190
bool restart(void)
Restart the host port.
bool setHeader(unsigned int header)
Set the header.
sockpp::udp_socket client
Socket object.
Definition: HostPortUDP.h:182
bool begin(const std::string &ipaddr, unsigned short port)
Begin the host port.
bool begin(const std::string &ipaddr, unsigned short port, unsigned int header, unsigned int terminator, unsigned int timeout)
Begin the host port.
bool close(void)
Close the host port.