本页内容

QModbusTcpConnectionObserver Class

QModbusTcpConnectionObserver 类表示可传递给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 。否则,套接字将被关闭或拒绝。

© 2026 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.