|
BAOS SDK v2
1.2.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
|
Base class for a TCP input output connection. More...
#include <baos/ip/TcpIO.h>
Public Types | |
| 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. | |
Public Member Functions | |
| TcpIO (BaosMsgQueue &msgQueue, wzcpp::ExecutorBase &executor) | |
| Construct a new TcpIO object with a given message queue and executor. | |
| void | send (const Buffer &buf) |
| Send a byte list out. | |
| void | open (const std::string &ip4Address, std::uint16_t port) |
| Open the TCP connection to the remote device. | |
| 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. | |
Protected Attributes | |
| 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. | |
| bool | stopped_ {false} |
| std::atomic< bool > | isOpen_ {false} |
| Flag to show if the TCP connection is open or not. | |
| 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. | |
| std::unique_ptr< Ip4Driver > | driver_ |
| The driver to use for actual sending and receiving. | |
| PacketizerBase::UPtr | packetizer_ |
| TCP stream packetizer used by this class. | |
Static Protected Attributes | |
| 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 | ( | BaosMsgQueue & | msgQueue, |
| wzcpp::ExecutorBase & | executor | ||
| ) |
Construct a new TcpIO object with a given message queue and executor.
| msgQueue | An external message queue to post events into |
| executor | An external executor to run this class worker in |
Open the TCP connection to the remote device.
| ip4Address | The IPv4 Address as string in the form "xxx.xxx.xxx.xxx" |
| port | The tcp port of the remote device |
| bool isOpen | ( | ) |
Get the open state of the TCP connection.
Flag to show the actual state of the receive worker. Because condition variables may suffer from spurious wakeups.