 |
helics
2.8.1
|
9 #include "CommsInterface.hpp"
10 #include "helics/helics-config.h"
23 int findOpenPort(
int count,
const std::string& host =
"localhost");
24 void setStartingPortNumber(
int startPort) { startingPort = startPort; }
25 int getDefaultStartingPort()
const {
return startingPort; }
26 void addUsedPort(
int port);
27 void addUsedPort(
const std::string& host,
int port);
30 int startingPort = -1;
31 std::map<std::string, std::set<int>> usedPort;
32 std::map<std::string, int> nextPorts;
33 bool isPortUsed(
const std::string& host,
int port)
const;
40 CommsInterface::thread_generation::dual) noexcept;
53 virtual void setFlag(
const std::string& flag,
bool val)
override;
64 std::atomic<bool> hasBroker{
false};
68 PortAllocator openPorts;
std::string brokerTargetAddress
the base for the broker address
Definition: CommsInterface.hpp:125
bool propertyLock()
Definition: CommsInterface.cpp:152
@ udp
using udp ports for communication
global_federate_id source_id
12 – for federate_id or route_id
Definition: ActionMessage.hpp:36
void removeProtocol(std::string &networkAddress)
Definition: NetworkBrokerData.cpp:265
int connectionPort
the port number for connecting
Definition: NetworkBrokerData.hpp:53
std::string name
the name of the object
Definition: CommsInterface.hpp:123
bool use_os_port
Definition: NetworkBrokerData.hpp:61
thread_generation
Definition: CommsInterface.hpp:30
void setPortNumber(int localPortNumber)
Definition: NetworkCommsInterface.cpp:158
std::atomic< int > PortNumber
port to use for the local connection
Definition: NetworkCommsInterface.hpp:57
virtual void setFlag(const std::string &flag, bool val)
Definition: CommsInterface.cpp:530
bool appendNameToAddress
flag indicating that the name should be appended to the address
Definition: NetworkBrokerData.hpp:64
Definition: global_federate_id.hpp:68
@ local
just open local ports
std::string brokerInitString
the initialization string for any automatically generated broker
Definition: CommsInterface.hpp:128
int getPortNumber() const
Definition: NetworkCommsInterface.hpp:49
Definition: NetworkBrokerData.hpp:36
std::string getAddress() const
Definition: NetworkCommsInterface.cpp:228
Definition: ActionMessage.hpp:29
ActionMessage generateReplyToIncomingMessage(ActionMessage &cmd)
Definition: NetworkCommsInterface.cpp:194
uint16_t counter
26 counter for filter tracking or message counter
Definition: ActionMessage.hpp:40
int brokerPort
the port number to use for the main broker interface
Definition: NetworkBrokerData.hpp:52
bool useOsPortAllocation
use the operating system to allocate a port number
Definition: NetworkCommsInterface.hpp:59
void setBrokerPort(int brokerPortNumber)
Definition: NetworkCommsInterface.cpp:138
void setAutomaticPortStartPort(int startingPort)
Definition: NetworkCommsInterface.cpp:169
interface_networks
Definition: NetworkBrokerData.hpp:16
bool autoPortNumber
use an automatic port numbering based on broker responses
Definition: NetworkCommsInterface.hpp:58
std::string generateMatchingInterfaceAddress(const std::string &server, interface_networks network)
Definition: NetworkBrokerData.cpp:582
int32_t messageID
8 – message ID for a variety of purposes
Definition: ActionMessage.hpp:35
void setExtraData(int32_t data)
Definition: ActionMessage.hpp:157
bool useJsonSerialization
true to make all connections use JSON serialization
Definition: CommsInterface.hpp:142
virtual int getDefaultBrokerPort() const =0
int brokerPort
standardized broker port to use for connection to the brokers
Definition: NetworkCommsInterface.hpp:56
bool noAckConnection
Definition: NetworkBrokerData.hpp:66
std::string localTargetAddress
the base for the receive address
Definition: CommsInterface.hpp:124
std::string brokerName
the identifier for the broker
Definition: CommsInterface.hpp:126
NetworkCommsInterface(interface_type type, CommsInterface::thread_generation threads=CommsInterface::thread_generation::dual) noexcept
Definition: NetworkCommsInterface.cpp:17
Definition: CommsInterface.hpp:26
int portStart
the starting port for automatic port definitions
Definition: NetworkBrokerData.hpp:55
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo) override
Definition: NetworkCommsInterface.cpp:77
bool noAckConnection
flag to bypass the connection acknowledge requirement
Definition: NetworkCommsInterface.hpp:61
@ tcp
using tcp ports for communication
bool isProtocolCommand(const ActionMessage &command) noexcept
Definition: ActionMessage.hpp:226
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
int findOpenPort(int count, const std::string &host)
Definition: NetworkCommsInterface.cpp:146
virtual void loadNetworkInfo(const NetworkBrokerData &netInfo)
Definition: CommsInterface.cpp:104
interface_type
Definition: NetworkBrokerData.hpp:24
bool serverMode
some comms have a server mode and non-server mode
Definition: CommsInterface.hpp:140
std::string makePortAddress(const std::string &networkInterface, int portNumber)
Definition: NetworkBrokerData.cpp:216
int getPort() const
Definition: NetworkCommsInterface.hpp:78
virtual void setFlag(const std::string &flag, bool val) override
Definition: NetworkCommsInterface.cpp:177
@ ipv4
use external ipv4 ports
bool mRequireBrokerConnection
specify that the comms should assume we have a broker
Definition: CommsInterface.hpp:138
Definition: NetworkCommsInterface.hpp:18
std::string stripProtocol(const std::string &networkAddress)
Definition: NetworkBrokerData.cpp:256
int portNumber
the port number for the local interface
Definition: NetworkBrokerData.hpp:51
bool appendNameToAddress
flag to append the name to the network address
Definition: NetworkCommsInterface.hpp:60
bool useJsonSerialization
for message serialization use JSON
Definition: NetworkBrokerData.hpp:68
int maxRetries
the maximum number of retries to establish a network connection
Definition: NetworkBrokerData.hpp:58