QCoapQUdpConnection Class

The QCoapQUdpConnection class handles the transfer of frames to and from a server. More...

Header: #include <QCoapQUdpConnection>
Inherits: QCoapConnection

Public Functions

QCoapQUdpConnection(QtCoap::SecurityMode securityMode = QtCoap::SecurityMode::NoSecurity, QObject *parent = nullptr)
QUdpSocket *socket() const

Public Slots

void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)

Protected Functions

QCoapQUdpConnection(QCoapQUdpConnectionPrivate &dd, QObject *parent = nullptr)
void createSocket()

Reimplemented Protected Functions

virtual void bind(const QString &host, quint16 port) override
virtual void close() override
virtual void writeData(const QByteArray &data, const QString &host, quint16 port) override

Detailed Description

\internal

\inmoduleQtCoap

\reentrant

The QCoapQUdpConnection class is used by the QCoapClient class to send requests to a server. It has a socket listening for UDP messages, that is used to send the CoAP frames.

When a reply is available, the QCoapQUdpConnection object emits a readyRead() signal.

See also QCoapClient.

Member Function Documentation

[explicit] QCoapQUdpConnection::QCoapQUdpConnection(QtCoap::SecurityMode securityMode = QtCoap::SecurityMode::NoSecurity, QObject *parent = nullptr)

Constructs a new QCoapQUdpConnection for the given securityMode and sets parent as the parent object.

Note: Since QtCoap::RawPublicKey is not supported yet, the connection will fall back to the QtCoap::NoSecurity in the QtCoap::RawPublicKey mode. That is, the connection won't be secure in this mode.

[explicit protected] QCoapQUdpConnection::QCoapQUdpConnection(QCoapQUdpConnectionPrivate &dd, QObject *parent = nullptr)

\internal

Constructs a new QCoapQUdpConnection as a child of parent, with dd as its d_ptr. This constructor must be used when internally subclassing the QCoapQUdpConnection class.

[override virtual protected] void QCoapQUdpConnection::bind(const QString &host, quint16 port)

\internal

Prepares the socket for data transmission to the given host and port by binding the socket. In case of a secure connection also starts the handshake with the server. Emits the bound() signal when the transport is ready.

[override virtual protected] void QCoapQUdpConnection::close()

\internal

Close the UDP socket

In the case of a secure connection, this also interrupts any ongoing hand-shake and shuts down the DTLS connection.

[protected] void QCoapQUdpConnection::createSocket()

\internal

Creates the socket used by the connection and sets it in connection's private class.

[slot] void QCoapQUdpConnection::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)

\internal

Sets the QUdpSocket socket option to value.

QUdpSocket *QCoapQUdpConnection::socket() const

\internal

Returns the socket.

[override virtual protected] void QCoapQUdpConnection::writeData(const QByteArray &data, const QString &host, quint16 port)

\internal

Sends the given data frame to the host at the port.