Coverage Report

Created: 2026-01-25 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/network/socket/qudpsocket.h
Line
Count
Source
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#ifndef QUDPSOCKET_H
6
#define QUDPSOCKET_H
7
8
#include <QtNetwork/qtnetworkglobal.h>
9
#include <QtNetwork/qabstractsocket.h>
10
#include <QtNetwork/qhostaddress.h>
11
12
QT_BEGIN_NAMESPACE
13
14
15
#ifndef QT_NO_UDPSOCKET
16
17
class QNetworkDatagram;
18
class QNetworkInterface;
19
class QUdpSocketPrivate;
20
21
class Q_NETWORK_EXPORT QUdpSocket : public QAbstractSocket
22
{
23
0
    Q_OBJECT
24
0
public:
25
0
    explicit QUdpSocket(QObject *parent = nullptr);
26
0
    virtual ~QUdpSocket();
27
0
28
0
#if QT_VERSION < QT_VERSION_CHECK(7,0,0) && !defined(Q_QDOC)
29
0
    // ### Qt7: move into QAbstractSocket
30
0
    using QAbstractSocket::bind;
31
0
    bool bind(QHostAddress::SpecialAddress addr, quint16 port = 0, BindMode mode = DefaultForPlatform)
32
0
    { return bind(QHostAddress(addr), port, mode); }
33
#endif
34
35
#ifndef QT_NO_NETWORKINTERFACE
36
    bool joinMulticastGroup(const QHostAddress &groupAddress);
37
    bool joinMulticastGroup(const QHostAddress &groupAddress,
38
                            const QNetworkInterface &iface);
39
    bool leaveMulticastGroup(const QHostAddress &groupAddress);
40
    bool leaveMulticastGroup(const QHostAddress &groupAddress,
41
                             const QNetworkInterface &iface);
42
43
    QNetworkInterface multicastInterface() const;
44
    void setMulticastInterface(const QNetworkInterface &iface);
45
#endif
46
47
    bool hasPendingDatagrams() const;
48
    qint64 pendingDatagramSize() const;
49
    QNetworkDatagram receiveDatagram(qint64 maxSize = -1);
50
    qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *host = nullptr, quint16 *port = nullptr);
51
52
    qint64 writeDatagram(const QNetworkDatagram &datagram);
53
    qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &host, quint16 port);
54
    inline qint64 writeDatagram(const QByteArray &datagram, const QHostAddress &host, quint16 port)
55
0
        { return writeDatagram(datagram.constData(), datagram.size(), host, port); }
56
57
private:
58
    Q_DISABLE_COPY_MOVE(QUdpSocket)
59
    Q_DECLARE_PRIVATE(QUdpSocket)
Unexecuted instantiation: QUdpSocket::d_func()
Unexecuted instantiation: QUdpSocket::d_func() const
60
};
61
62
#endif // QT_NO_UDPSOCKET
63
64
QT_END_NAMESPACE
65
66
#endif // QUDPSOCKET_H