BAOS SDK v2  1.2.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
Loading...
Searching...
No Matches
TransportTcpIO.h
Go to the documentation of this file.
1//
2// Copyright (c) 2002-2026 WEINZIERL ENGINEERING GmbH
3// All rights reserved.
4//
5// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
8// SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
9// WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
10// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
11//
12
13#ifndef __BAOSLIB_TRANSPORT_TCP_IO_H__
14#define __BAOSLIB_TRANSPORT_TCP_IO_H__
15
16#include "baos/BaosLib_export.h"
17#include "baos/config.h"
19#include "baos/ip/TcpIO.h"
20#include "wzcpp/features/concurrent/executor.h"
22
24#include <array>
25#include <atomic>
26#include <memory>
27#include <string>
29
30
35namespace wz::baos::ip
36{
37class Ip4Driver;
38}
39
40namespace wz::baos::transport
41{
42
43
44/******************************************************************
45 * TransportTcpIO
46 ******************************************************************/
47
53class BAOSLIB_EXPORT TransportTcpIO: public TransportIO
54{
55public:
56 using UPtr = std::unique_ptr<TransportTcpIO>;
57 using UniqueLock = std::unique_lock<std::mutex>;
58
66 TransportTcpIO(BaosMsgQueue& msgQueue, wzcpp::ExecutorBase& executor, wzcpp::TimerManager<Clock>& timerManager);
67
69
77 TransportTcpIO(BaosMsgQueue& msgQueue, std::unique_ptr<ip::Ip4Driver>& driver, wzcpp::ExecutorBase& executor, wzcpp::TimerManager<Clock>& timerManager);
78
84 ip::Ip4Driver& getDriver();
86
88
89 void stop() override;
90
96 void send(const Buffer& buf) override;
97
104 void open(const std::string& ip4Address, std::uint16_t port);
105 void open(IOEvent::EventDataType arg);
106
110 void close() override;
111
115 void waitForFinished() override;
116
122 bool isOpen() override;
123
124private:
125 void eventHandler() override;
126
127 void sendToIo(const Buffer& frame) override;
128
129protected:
131};
132
133} // namespace wz::baos::transport
134
135#endif //__BAOSLIB_TRANSPORT_TCP_IO_H__
Code regarding Input/Output Events.
Specialization for a TCP IP v4 BAOSConnection.
Base class for the transport protocol io used by BaosConnections.
std::variant< std::monostate, ip::Ip4SocketAddress, std::unique_ptr< Buffer >, TimerIdList > EventDataType
datatypes inside an IOEvent
Definition IOEvent.h:50
A specialization for (connection oriented) connection to the BAOS device via a TCP connection.
Definition BaosTcpConnection.h:182
Base class for a TCP input output connection.
Definition TcpIO.h:115
Base class for a Transport input output connection.
Definition TransportIO.h:56
Base class for a Transport input output connection.
Definition TransportTcpIO.h:54
TransportTcpIO(BaosMsgQueue &msgQueue, wzcpp::ExecutorBase &executor, wzcpp::TimerManager< Clock > &timerManager)
Construct a new TransportTcpIO object with a given message queue and executor.
ip::TcpIO tcpIO_
Definition TransportTcpIO.h:130
void waitForFinished() override
Wait till the worker of this class has finished.
void send(const Buffer &buf) override
Send a byte list out.
std::unique_lock< std::mutex > UniqueLock
Alias for unique lock used by this class.
Definition TransportTcpIO.h:57
void close() override
Close the Transport connection.
void open(const std::string &ip4Address, std::uint16_t port)
Open the TCP connection to the remote device.
std::unique_ptr< TransportTcpIO > UPtr
Alias for a std::unique_ptr to this class.
Definition TransportTcpIO.h:56
bool isOpen() override
Get the open state of the Transport connection.
Global types and configuration for the whole SDK.
std::vector< std::uint8_t > Buffer
An alias type for a byte buffer.
Definition config.h:71
wzcpp::ConcurrentDeque< IOEvent > BaosMsgQueue
Alias for a concurrent queue with IOEvents.
Definition IOEvent.h:96