Base class for a TCP input output connection.
More...
#include <baos/ip/TcpIO.h>
|
using | UPtr = std::unique_ptr< TcpIO > |
| Alias for a std::unique_ptr to this class.
|
|
using | UniqueLock = std::unique_lock< std::mutex > |
| Alias for unique lock used by this class.
|
|
|
| TcpIO (BaosMsgQueue &msgQueue, wzcpp::ExecutorBase &executor) |
| Construct a new TcpIO object with a given message queue and executor. More...
|
|
void | send (const Buffer &buf) |
| Send a byte list out. More...
|
|
void | open (const std::string &ip4Address, std::uint16_t port) |
| Open the TCP connection to the remote device. More...
|
|
void | close () |
| Close the TCP connection.
|
|
void | waitForFinished () |
| Wait till the worker of this class has finished.
|
|
bool | isOpen () |
| Get the open state of the TCP connection. More...
|
|
|
std::unique_ptr< Ip4Driver > | driver_ |
| The driver to use for actual sending and receiving.
|
|
std::atomic< bool > | rxShouldStop_ {false} |
| Flag to indicate that the receiver worker should stop.
|
|
std::condition_variable | cvFinished_ |
| Condition variable which is set when the receiver worker has stopped.
|
|
std::mutex | cvFinished_mut_ |
| The correponding mutex for the cvFinished_ condition variable.
|
|
std::atomic< bool > | stopped_ {false} |
|
std::atomic< bool > | isOpen_ {false} |
| Flag to show if the TCP connection is open or not.
|
|
PacketizerBase::UPtr | packetizer_ |
| TCP stream packetizer used by this class.
|
|
BaosMsgQueue & | msgQueue_ |
| Reference to the message queue in which events will be posted by this class.
|
|
wzcpp::ExecutorBase & | executor_ |
| Reference to the executor to use for running the receive(RX) worker.
|
|
|
static std::atomic< std::uint64_t > | msgId |
| Used to generate a continuous unique message id.
|
|
Base class for a TCP input output connection.
This establishes a TCP connection to the BAOS devices. It sends and receives raw bytes.
◆ TcpIO()
Construct a new TcpIO object with a given message queue and executor.
- Parameters
-
msgQueue | An external message queue to post events into |
executor | An external executor to run this class worker in |
◆ send()
void send |
( |
const Buffer & |
buf | ) |
|
Send a byte list out.
- Parameters
-
◆ open()
void open |
( |
const std::string & |
ip4Address, |
|
|
std::uint16_t |
port |
|
) |
| |
Open the TCP connection to the remote device.
- Parameters
-
ip4Address | The IPv4 Address as string in the form "xxx.xxx.xxx.xxx" |
port | The tcp port of the remote device |
◆ isOpen()
Get the open state of the TCP connection.
- Returns
- true if the TCP connection is established false otherwise
◆ stopped_
std::atomic<bool> stopped_ {false} |
|
protected |
Flag to show the actual state of the receive worker. Because condition variables may suffer from spurious wakeups.
The documentation for this class was generated from the following file: