7#include "sockpp/tcp_connector.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;
180 static constexpr unsigned int MASK = 0xFF;
189 bool init(
const std::string& ipaddr,
unsigned short port,
unsigned int timeout);
A class for host communication via TCP/IP protocol.
Definition: HostPortTCP.h:20
bool restart(void)
Restart the host port.
bool setTerminator(unsigned int terminator)
Set the terminator.
bool isInit(void)
Check if host port is open.
std::string _ip
IP address.
Definition: HostPortTCP.h:183
static constexpr unsigned int HEADER
Default header.
Definition: HostPortTCP.h:173
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.
std::string getIP(void)
Get the IP address.
bool flush(void)
Flush the port.
bool setHeader(unsigned int header)
Set the header.
HostPortTCP()
Constructor.
unsigned int _header
Header bytes.
Definition: HostPortTCP.h:185
unsigned int getTimeout(void)
Get the timeout.
unsigned int _terminator
Terminator bytes.
Definition: HostPortTCP.h:184
bool init(const std::string &ipaddr, unsigned short port, unsigned int timeout)
Private initialization function.
~HostPortTCP()
Desctructor.
unsigned int _port
Socket port.
Definition: HostPortTCP.h:182
bool setTimeout(unsigned int timeout)
Set the timeout.
unsigned short getPort(void)
Get the serial port.
unsigned int _timeout
Timeout.
Definition: HostPortTCP.h:186
bool begin(const std::string &ipaddr, unsigned short port, unsigned int header, unsigned int terminator)
Begin the host port.
unsigned int getHeader(void)
Get the header.
bool _isFirstRead
True if firt packer read.
Definition: HostPortTCP.h:188
sockpp::tcp_connector client
Socket object.
Definition: HostPortTCP.h:181
bool close(void)
Close the host port.
sockpp::socket_initializer sockInit
Definition: HostPortTCP.h:179
static constexpr unsigned int TERMINATOR
Default terminator.
Definition: HostPortTCP.h:174
unsigned int getTerminator(void)
Get the terminator.
bool setIP(const std::string &ipaddr)
Set the IP address.
static constexpr unsigned int TIMEOUT
Default timeout.
Definition: HostPortTCP.h:175
bool setPort(unsigned short port)
Set the serial port.
static constexpr unsigned int MASK
Mask for parsing.
Definition: HostPortTCP.h:180
bool write(unsigned char *packetPtr, unsigned int size)
Write data buffer.
bool read(unsigned char *packetPtr, unsigned int size)
Read data buffer.