QModbusTcpConnectionObserver Class

QModbusTcConnectionObserver 类表示可传递给QModbusTcpServer::installConnectionObserver 的对象的接口。更多

头文件: #include <QModbusTcpConnectionObserver>
CMake: find_package(Qt6 REQUIRED COMPONENTS SerialBus)
target_link_libraries(mytarget PRIVATE Qt6::SerialBus)
qmake: QT += serialbus

公共函数

virtual bool acceptNewConnection(QTcpSocket *newClient) = 0

详细说明

开发人员必须实现该接口,才能监控来自其他 Modbus 客户端的每个传入 TCP 连接。

另请参阅 QModbusTcpServer::installConnectionObserver

成员函数文档

[pure virtual] bool QModbusTcpConnectionObserver::acceptNewConnection(QTcpSocket *newClient)

该函数是每个传入 TCP 连接的回调函数。用户应提供newClient ,以便在建立新客户端连接时接收通知,并确定是否接受该连接。

如果连接被接受,函数应返回true 。否则,套接字将被关闭/拒绝。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.