QDnsServiceRecord Class

QDnsServiceRecord 类存储有关 DNS SRV 记录的信息。更多

头文件: #include <QDnsServiceRecord>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

公共函数

QDnsServiceRecord()
QDnsServiceRecord(const QDnsServiceRecord &other)
~QDnsServiceRecord()
QString name() const
quint16 port() const
quint16 priority() const
void swap(QDnsServiceRecord &other)
QString target() const
quint32 timeToLive() const
quint16 weight() const
QDnsServiceRecord &operator=(const QDnsServiceRecord &other)

详细说明

对服务执行查询时,将返回零条或多条记录。每条记录由一个 QDnsServiceRecord 实例表示。

RFC 2782 中定义了字段的含义。

另请参阅 QDnsLookup

成员函数文档

QDnsServiceRecord::QDnsServiceRecord()

构造一个空的服务记录对象。

QDnsServiceRecord::QDnsServiceRecord(const QDnsServiceRecord &other)

构造other 的副本。

[noexcept] QDnsServiceRecord::~QDnsServiceRecord()

销毁服务记录。

QString QDnsServiceRecord::name() const

返回此记录的名称。

quint16 QDnsServiceRecord::port() const

返回此服务记录在目标主机上的端口。

quint16 QDnsServiceRecord::priority() const

返回此服务记录的优先级。

客户端必须尝试联系优先级最低的目标主机。

[noexcept] void QDnsServiceRecord::swap(QDnsServiceRecord &other)

将此服务记录实例与other 互换。该操作速度非常快,从未出现过故障。

QString QDnsServiceRecord::target() const

返回此服务记录的目标主机域名。

quint32 QDnsServiceRecord::timeToLive() const

返回该记录的有效期(以秒为单位)。

quint16 QDnsServiceRecord::weight() const

返回此服务记录的权重。

权重字段指定了具有相同优先级的条目的相对权重。权重越高的条目被选中的可能性越大。

QDnsServiceRecord &QDnsServiceRecord::operator=(const QDnsServiceRecord &other)

other 对象的数据赋值给此记录对象,并返回一个引用。

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