![]() |
dnp3 (C++ API) 1.8.0-RC1
|
Builder for configuring connection parameters. More...
#include <dnp3.hpp>
Public Member Functions | |
| ConnectionInfo (ConnectionInfo &&other) noexcept | |
| Transfer ownership of the underlying C-type to this instance and invalidate the other instance. More... | |
| ConnectionInfo () | |
| Create a new ConnectionInfo. You must call set_endpoint() before using it. More... | |
| ~ConnectionInfo () | |
| Destroy a ConnectionInfo instance. More... | |
| ParamError | set_endpoint (const std::string &endpoint) |
| Set the endpoint to connect to. More... | |
| void | set_timeout (std::chrono::steady_clock::duration timeout_ms) |
| Set the connection timeout. More... | |
| void | clear_timeout () |
| Clear any previously configured timeout so the OS default is used. More... | |
| ParamError | set_local_endpoint (const std::string &local_endpoint) |
| Set the local endpoint to bind to. More... | |
| void | clear_local_endpoint () |
| Clear any previously configured local endpoint so the OS chooses the interface and port. More... | |
| ParamError | set_master_address (uint16_t address) |
| Change the master address for this and all subsequent connections. More... | |
Friends | |
| class | CppConnectionInfoFriend |
Builder for configuring connection parameters.
Instances are passed to NextEndpointAction::connect_to() inside ClientConnectionHandler::next().
You may construct a new instance for each callback to ClientConnectionHandler::next() or reuse a single instance to reduce allocations.
When reusing, call ConnectionInfo::clear_timeout() or ConnectionInfo::clear_local_endpoint() before setting new values if you need to revert to the default timeout or adapter selection.
|
inlinenoexcept |
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
| other | Class from which ownership will be transfer to this instance |
| dnp3::ConnectionInfo::ConnectionInfo | ( | ) |
Create a new ConnectionInfo. You must call set_endpoint() before using it.
| dnp3::ConnectionInfo::~ConnectionInfo | ( | ) |
Destroy a ConnectionInfo instance.
| void dnp3::ConnectionInfo::clear_local_endpoint | ( | ) |
Clear any previously configured local endpoint so the OS chooses the interface and port.
| void dnp3::ConnectionInfo::clear_timeout | ( | ) |
Clear any previously configured timeout so the OS default is used.
| ParamError dnp3::ConnectionInfo::set_endpoint | ( | const std::string & | endpoint | ) |
Set the endpoint to connect to.
This method must be called before passing the ConnectionInfo to connect_to()
| endpoint | Endpoint to connect to (hostname or IP:port) |
| ParamError dnp3::ConnectionInfo::set_local_endpoint | ( | const std::string & | local_endpoint | ) |
Set the local endpoint to bind to.
Optional: If not called, the OS will select the network adapter based on the routing table for the destination address, and assign an ephemeral port.
This is primarily useful for enforcing network segmentation in multi-homed systems, such as OT gateways that bridge device and enterprise networks. By explicitly binding to a specific adapter, you ensure traffic goes out the correct interface regardless of routing table configuration.
Typically you should specify port 0 to let the OS assign an ephemeral port while forcing a specific network adapter. Using a specific non-zero port is rarely needed for client connections and may cause bind failures if the port is already in use.
| local_endpoint | Local address to bind to |
| ParamError dnp3::ConnectionInfo::set_master_address | ( | uint16_t | address | ) |
Change the master address for this and all subsequent connections.
Optional: The master address change is persistent and remains active across reconnections until explicitly changed again.
This is useful when an outstation needs to communicate with different masters at different endpoints, such as during failover scenarios or when connecting to a backup master.
If not called, the outstation uses the master address specified in its configuration.
| address | Master link-layer address |
| void dnp3::ConnectionInfo::set_timeout | ( | std::chrono::steady_clock::duration | timeout_ms | ) |
Set the connection timeout.
Optional: If not called, the operating system's default timeout will be used
| timeout_ms | Connection timeout |