Handle to the running server. The server runs on a background task until this class is destroyed.
More...
#include <rodbus.hpp>
|
| | Server (Server &&other) noexcept |
| | Transfer ownership of the underlying C-type to this instance and invalidate the other instance. More...
|
| |
| | ~Server () |
| | Shutdown and release all resources of a running server. More...
|
| |
| void | update_database (uint8_t unit_id, DatabaseCallback &transaction) |
| | Update the database associated with a particular unit id. If the unit id exists, lock the database and call user code to perform the transaction. More...
|
| |
| void | set_decode_level (const DecodeLevel &level) |
| | Set the decoding level for the server. More...
|
| |
|
| static Server | create_tcp (Runtime &runtime, const std::string &address, uint16_t port, AddressFilter &filter, uint16_t max_sessions, DeviceMap &endpoints, const DecodeLevel &decode_level) |
| | Launch a TCP server. More...
|
| |
| static Server | create_rtu (Runtime &runtime, const std::string &path, const SerialPortSettings &serial_params, const RetryStrategy &retry, DeviceMap &endpoints, const DecodeLevel &decode_level) |
| | Launch a RTU server. More...
|
| |
| static Server | create_tls_with_authz (Runtime &runtime, const std::string &address, uint16_t port, AddressFilter &filter, uint16_t max_sessions, DeviceMap &endpoints, const TlsServerConfig &tls_config, std::unique_ptr< AuthorizationHandler > authorization_handler, const DecodeLevel &decode_level) |
| | Create a Modbus Security (TLS) server. More...
|
| |
| static Server | create_tls (Runtime &runtime, const std::string &address, uint16_t port, AddressFilter &filter, uint16_t max_sessions, DeviceMap &endpoints, const TlsServerConfig &tls_config, const DecodeLevel &decode_level) |
| | Create a TLS server that does NOT require the client role extension. More...
|
| |
Handle to the running server. The server runs on a background task until this class is destroyed.
◆ Server()
| rodbus::Server::Server |
( |
Server && |
other | ) |
|
|
inlinenoexcept |
Transfer ownership of the underlying C-type to this instance and invalidate the other instance.
- Note
- the moved class will now throw an exception if any method is called
- Parameters
-
| other | Class from which ownership will be transfer to this instance |
◆ ~Server()
| rodbus::Server::~Server |
( |
| ) |
|
Shutdown and release all resources of a running server.
◆ create_rtu()
Launch a RTU server.
- Parameters
-
| runtime | runtime on which to spawn the server |
| path | Path to the serial device. Generally /dev/tty0 on Linux and COM1 on Windows. |
| serial_params | Serial port settings |
| retry | Parameters that control How long to wait before re-opening the serial port |
| endpoints | map of endpoints which is emptied upon passing to this function |
| decode_level | Decode levels for this server |
- Returns
- RTU server instance
- Exceptions
-
◆ create_tcp()
Launch a TCP server.
Recommended port for Modbus is 502.
When the maximum number of concurrent sessions is reached, the oldest session is closed.
- Parameters
-
| runtime | runtime on which to spawn the server |
| address | Local IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter |
| port | Port on which to listen |
| filter | Filter used to limit which IP address(es) can connect |
| max_sessions | Maximum number of concurrent sessions. When a new connection would exceed it, the oldest session is closed. Zero is treated as one. |
| endpoints | Map of endpoints which is emptied upon passing to this function |
| decode_level | Decode levels for this server |
- Returns
- TCP server instance
- Exceptions
-
◆ create_tls()
Create a TLS server that does NOT require the client role extension.
This functionality is not standardized by Modbus.org, but nevertheless is commonly implemented
When the maximum number of concurrent sessions is reached, the oldest session is closed.
- Parameters
-
| runtime | runtime on which to spawn the server |
| address | Local IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter |
| port | Port on which to listen |
| filter | Filter used to limit which IP address(es) can connect |
| max_sessions | Maximum number of concurrent sessions. A connection becomes a session once its TLS handshake completes; if that exceeds the maximum, the oldest session is closed. Handshakes run one at a time, each limited to 5 seconds. Zero is treated as one. |
| endpoints | map of endpoints which is emptied upon passing to this function |
| tls_config | TLS server configuration |
| decode_level | Decode levels for this server |
- Returns
- Modbus Security (TLS) server instance
- Exceptions
-
◆ create_tls_with_authz()
Create a Modbus Security (TLS) server.
This server requires that the client certificate contains the role extension and authorizes each request against the supplied handler.
Recommended port for Modbus Security is 802.
When the maximum number of concurrent sessions is reached, the oldest session is closed.
- Parameters
-
| runtime | runtime on which to spawn the server |
| address | Local IP (v4/v6) address. Accepts '0.0.0.0' (all adapters), '127.0.0.1' (localhost), or the address of a particular network adapter |
| port | Port on which to listen |
| filter | Filter used to limit which IP address(es) can connect |
| max_sessions | Maximum number of concurrent sessions. A connection becomes a session once its TLS handshake completes; if that exceeds the maximum, the oldest session is closed. Handshakes run one at a time, each limited to 5 seconds. Zero is treated as one. |
| endpoints | map of endpoints which is emptied upon passing to this function |
| tls_config | TLS server configuration |
| authorization_handler | Authorization handler |
| decode_level | Decode levels for this server |
- Returns
- Modbus Security (TLS) server instance
- Exceptions
-
◆ set_decode_level()
| void rodbus::Server::set_decode_level |
( |
const DecodeLevel & |
level | ) |
|
Set the decoding level for the server.
- Parameters
-
- Exceptions
-
◆ update_database()
| void rodbus::Server::update_database |
( |
uint8_t |
unit_id, |
|
|
DatabaseCallback & |
transaction |
|
) |
| |
Update the database associated with a particular unit id. If the unit id exists, lock the database and call user code to perform the transaction.
- Parameters
-
| unit_id | Unit id of the database to update |
| transaction | Callback invoked when a lock has been acquired |
- Exceptions
-
The documentation for this class was generated from the following file: