| helics 3.6.1

TcpComms.h
1 /*
2 Copyright (c) 2017-2025,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #pragma once
8
9 #include "../NetworkCommsInterface.hpp"
10 #include "gmlc/containers/BlockingQueue.hpp"
11
12 #include <atomic>
13 #include <memory>
14 #include <set>
15 #include <string>
16
17 namespace gmlc::networking {
18 class AsioContextManager;
19 class TcpConnection;
20 } // namespace gmlc::networking
21
22 namespace helics::tcp {
23
25 class TcpComms final: public NetworkCommsInterface {
26 public:
28 TcpComms() noexcept;
30 ~TcpComms();
32 virtual void loadNetworkInfo(const NetworkBrokerData& netInfo) override;
33
34 virtual void setFlag(std::string_view flag, bool val) override;
35
36 private:
37 bool reuse_address{false};
38 std::string encryption_config;
39 virtual int getDefaultBrokerPort() const override;
40 virtual void queue_rx_function() override;
41 virtual void queue_tx_function() override;
42
43 virtual void closeReceiver() override;
44
46 bool establishBrokerConnection(
47 std::shared_ptr<gmlc::networking::AsioContextManager>& ioctx,
48 std::shared_ptr<gmlc::networking::TcpConnection>& brokerConnection);
51 int processIncomingMessage(ActionMessage&& cmd);
52 // promise and future for communicating port number from tx_thread to rx_thread
53 gmlc::containers::BlockingQueue<ActionMessage> rxMessageQueue;
54
55 void txReceive(const char* data, size_t bytes_received, const std::string& errorMessage);
56
63 size_t dataReceive(gmlc::networking::TcpConnection* connection,
64 const char* data,
65 size_t bytes_received);
66
67 // bool errorHandle()
68 };
69
70 } // namespace helics::tcp
helics::ActionMessage
Definition: ActionMessage.hpp:30
helics::NetworkBrokerData
Definition: NetworkBrokerData.hpp:23
helics::NetworkCommsInterface
Definition: NetworkCommsInterface.hpp:18
helics::tcp::TcpComms
Definition: TcpComms.h:25
helics::tcp::TcpComms::~TcpComms
~TcpComms()
Definition: TcpComms.cpp:65
helics::tcp::TcpComms::TcpComms
TcpComms() noexcept
Definition: TcpComms.cpp:28
helics::tcp::TcpComms::setFlag
virtual void setFlag(std::string_view flag, bool val) override
Definition: TcpComms.cpp:47
helics::tcp::TcpComms::loadNetworkInfo
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo) override
Definition: TcpComms.cpp:36