Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qnetworkdatagram.h
Go to the documentation of this file.
1// Copyright (C) 2016 Intel Corporation.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QNETWORKDATAGRAM_H
5#define QNETWORKDATAGRAM_H
6
7#include <QtCore/qbytearray.h>
8#include <QtNetwork/qhostaddress.h>
9
10#ifndef QT_NO_UDPSOCKET
11
13
16
17class Q_NETWORK_EXPORT QNetworkDatagram
18{
19public:
21 QNetworkDatagram(const QByteArray &data, const QHostAddress &destinationAddress = QHostAddress(),
22 quint16 port = 0); // implicit
24 QNetworkDatagram &operator=(const QNetworkDatagram &other);
26 { if (d) destroy(d); }
27
29 : d(other.d)
30 { other.d = nullptr; }
32 { swap(other); return *this; }
33
34 void swap(QNetworkDatagram &other) noexcept
35 { qt_ptr_swap(d, other.d); }
36
37 void clear();
38 bool isValid() const;
39 bool isNull() const
40 { return !isValid(); }
41
42 uint interfaceIndex() const;
43 void setInterfaceIndex(uint index);
44
45 QHostAddress senderAddress() const;
46 QHostAddress destinationAddress() const;
47 int senderPort() const;
48 int destinationPort() const;
49 void setSender(const QHostAddress &address, quint16 port = 0);
50 void setDestination(const QHostAddress &address, quint16 port);
51
52 int hopLimit() const;
53 void setHopLimit(int count);
54
55 QByteArray data() const;
56 void setData(const QByteArray &data);
57
58#if defined(Q_COMPILER_REF_QUALIFIERS) || defined(Q_QDOC)
59 QNetworkDatagram makeReply(const QByteArray &payload) const &
60 { return makeReply_helper(payload); }
61 QNetworkDatagram makeReply(const QByteArray &payload) &&
62 { makeReply_helper_inplace(payload); return *this; }
63#else
65 { return makeReply_helper(paylaod); }
66#endif
67
68private:
70 friend class QUdpSocket;
71 friend class QSctpSocket;
72
74 QNetworkDatagram makeReply_helper(const QByteArray &data) const;
75 void makeReply_helper_inplace(const QByteArray &data);
76 static void destroy(QNetworkDatagramPrivate *d);
77};
78
79Q_DECLARE_SHARED(QNetworkDatagram)
80
82
84
85#endif // QT_NO_UDPSOCKET
86
87#endif // QNETWORKDATAGRAM_H
\inmodule QtCore
Definition qbytearray.h:57
The QHostAddress class provides an IP address.
The QNetworkDatagram class provides the data and metadata of a UDP datagram.
QNetworkDatagram makeReply(const QByteArray &paylaod) const
Creates a new QNetworkDatagram representing a reply to this incoming datagram and sets the payload da...
bool isNull() const
Returns true if this QNetworkDatagram object is null.
QNetworkDatagram(QNetworkDatagram &&other) noexcept
void swap(QNetworkDatagram &other) noexcept
Swaps this instance with other.
QNetworkDatagram & operator=(QNetworkDatagram &&other) noexcept
The QSctpSocket class provides an SCTP socket.
Definition qsctpsocket.h:17
\reentrant
Definition qudpsocket.h:21
b clear()
Combined button and popup list for selecting options.
EGLOutputPortEXT port
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1388
GLuint index
[2]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLuint64EXT address
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:29
unsigned short quint16
Definition qtypes.h:48
unsigned int uint
Definition qtypes.h:34
mimeData setData("text/csv", csvData)
QSharedPointer< T > other(t)
[5]
this swap(other)