helics 3.7.0
Loading...
Searching...
No Matches
TcpComms.h
1/*
2Copyright (c) 2017-2026,
3Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Energy
4Innovation LLC. See the top-level NOTICE for additional details. All rights reserved.
5SPDX-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
17namespace gmlc::networking {
18class AsioContextManager;
19class TcpConnection;
20} // namespace gmlc::networking
21
22namespace helics::tcp {
23
25class 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
Definition ActionMessage.hpp:30
Definition NetworkBrokerData.hpp:23
Definition NetworkCommsInterface.hpp:18
Definition TcpComms.h:25
virtual void setFlag(std::string_view flag, bool val) override
Definition TcpComms.cpp:62
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo) override
Definition TcpComms.cpp:51