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.cpp
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#include "qnetworkdatagram.h"
6
7#ifndef QT_NO_UDPSOCKET
8
10
12
13
114
120 : d(new QNetworkDatagramPrivate(data, destinationAddress, port))
121{
122}
123
133
136 : d(&dd)
137{
138}
139
146{
147 *d = *other.d;
148 return *this;
149}
150
156{
157 d->data.clear();
160 d->header.hopLimit = -1;
161 d->header.ifindex = 0;
162}
163
180
196
213
230
247
271
290
309{
310 return d->header.hopLimit;
311}
312
333
350{
351 return d->header.ifindex;
352}
353
379
391{
392 return d->data;
393}
394
406{
407 d->data = data;
408}
409
456{
457 // is it a multicast address?
458 return !addr.isMulticast();
459}
460
461QNetworkDatagram QNetworkDatagram::makeReply_helper(const QByteArray &data) const
462{
464 x->header.ifindex = d->header.ifindex;
466 x->header.senderAddress = d->header.destinationAddress;
467 x->header.senderPort = d->header.destinationPort;
468 }
469 return QNetworkDatagram(*x);
470}
471
472void QNetworkDatagram::makeReply_helper_inplace(const QByteArray &data)
473{
474 d->data = data;
475 d->header.hopLimit = -1;
480}
481
482void QNetworkDatagram::destroy(QNetworkDatagramPrivate *d)
483{
484 Q_ASSERT(d);
485 delete d;
486}
487
494
495#endif // QT_NO_UDPSOCKET
static constexpr auto UnknownNetworkLayerProtocol
\inmodule QtCore
Definition qbytearray.h:57
void clear()
Clears the contents of the byte array and makes it null.
The QHostAddress class provides an IP address.
void clear()
Sets the host address to null and sets the protocol to QAbstractSocket::UnknownNetworkLayerProtocol.
NetworkLayerProtocol protocol() const
Returns the network layer protocol of the host address.
QHostAddress senderAddress
QHostAddress destinationAddress
The QNetworkDatagram class provides the data and metadata of a UDP datagram.
int hopLimit() const
Returns the hop count limit associated with this datagram.
int senderPort() const
Returns the port number of the sender associated with this datagram.
QNetworkDatagram()
Creates a QNetworkDatagram object with no payload data and undefined destination address.
void clear()
Clears the payload data and metadata in this QNetworkDatagram object, resetting them to their default...
void setHopLimit(int count)
Sets the hop count limit associated with this datagram to count.
QHostAddress senderAddress() const
Returns the sender address associated with this datagram.
QByteArray data() const
Returns the data payload of this datagram.
uint interfaceIndex() const
Returns the interface index this datagram is associated with.
void setSender(const QHostAddress &address, quint16 port=0)
Sets the sender address associated with this datagram to be the address address and port number port.
QHostAddress destinationAddress() const
Returns the destination address associated with this datagram.
void setData(const QByteArray &data)
Sets the data payload of this datagram to data.
QNetworkDatagram & operator=(const QNetworkDatagram &other)
Copies the other datagram, including the payload and metadata.
bool isValid() const
Returns true if this QNetworkDatagram object is valid.
void setInterfaceIndex(uint index)
Sets the interface index this datagram is associated with to index.
int destinationPort() const
Returns the port number of the destination associated with this datagram.
void setDestination(const QHostAddress &address, quint16 port)
Sets the destination address associated with this datagram to be the address address and port number ...
Combined button and popup list for selecting options.
EGLOutputPortEXT port
#define QT_IMPL_METATYPE_EXTERN(TYPE)
Definition qmetatype.h:1390
static bool isNonMulticast(const QHostAddress &addr)
GLint GLint GLint GLint GLint x
[0]
GLuint index
[2]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum const void * addr
GLuint GLuint64EXT address
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
Definition qswap.h:20
unsigned short quint16
Definition qtypes.h:48
unsigned int uint
Definition qtypes.h:34
QSharedPointer< T > other(t)
[5]