72#ifndef QT_NO_UDPSOCKET
74#define QT_CHECK_BOUND(function, a) do { \
76 qWarning(function" called on a QUdpSocket when not in QUdpSocket::BoundState"); \
88 {
return doEnsureInitialized(bindAddress, bindPort,
QHostAddress()); }
91 {
return doEnsureInitialized(
QHostAddress(), 0, remoteAddress); }
94bool QUdpSocketPrivate::doEnsureInitialized(
const QHostAddress &bindAddress,
quint16 bindPort,
124 d_func()->isBuffered =
false;
136#ifndef QT_NO_NETWORKINTERFACE
177 return d->socketEngine->joinMulticastGroup(groupAddress, iface);
216 return d_func()->socketEngine->leaveMulticastGroup(groupAddress, iface);
235 return d->socketEngine->multicastInterface();
252 qWarning(
"QUdpSocket::setMulticastInterface() called on a QUdpSocket when not in QUdpSocket::BoundState");
255 d->socketEngine->setMulticastInterface(iface);
269 return d_func()->socketEngine->hasPendingDatagrams();
281 return d_func()->socketEngine->pendingDatagramSize();
309#if defined QUDPSOCKET_DEBUG
310 qDebug(
"QUdpSocket::writeDatagram(%p, %llu, \"%s\", %i)",
data,
size,
319 d->cachedSocketDescriptor =
d->socketEngine->socketDescriptor();
327 tr(
"Unable to send a datagram"));
330 d->setErrorAndEmit(
d->socketEngine->error(),
d->socketEngine->errorString());
373#if defined QUDPSOCKET_DEBUG
374 qDebug(
"QUdpSocket::writeDatagram(%p, %i, \"%s\", %i)",
385 qint64 sent =
d->socketEngine->writeDatagram(datagram.d->
data,
388 d->cachedSocketDescriptor =
d->socketEngine->socketDescriptor();
393 d->setErrorAndEmit(
d->socketEngine->error(),
d->socketEngine->errorString());
419#if defined QUDPSOCKET_DEBUG
420 qDebug(
"QUdpSocket::receiveDatagram(%lld)", maxSize);
425 maxSize =
d->socketEngine->pendingDatagramSize();
430 qint64 readBytes =
d->socketEngine->readDatagram(
result.d->data.data(), maxSize, &
result.d->header,
432 d->hasPendingData =
false;
433 d->socketEngine->setReadNotificationEnabled(
true);
435 d->setErrorAndEmit(
d->socketEngine->error(),
d->socketEngine->errorString());
439 result.d->data.truncate(readBytes);
463#if defined QUDPSOCKET_DEBUG
471 readBytes =
d->socketEngine->readDatagram(
data, maxSize, &
header,
478 readBytes =
d->socketEngine->readDatagram(
data, maxSize);
481 d->hasPendingData =
false;
482 d->socketEngine->setReadNotificationEnabled(
true);
484 if (readBytes == -2) {
487 tr(
"No datagram available for reading"));
490 d->setErrorAndEmit(
d->socketEngine->error(),
d->socketEngine->errorString());
499#include "moc_qudpsocket.cpp"
virtual bool isValid() const =0
QAbstractSocketEngine * socketEngine
void resolveProxy(const QString &hostName, quint16 port)
bool initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol)
The QAbstractSocket class provides the base functionality common to all socket types.
virtual bool bind(const QHostAddress &address, quint16 port=0, BindMode mode=DefaultForPlatform)
static constexpr auto UnknownNetworkLayerProtocol
bool isValid() const
Returns true if the socket is valid and ready for use; otherwise returns false.
SocketState state() const
Returns the state of the socket.
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
The QHostAddress class provides an IP address.
QString toString() const
Returns the address as a string.
NetworkLayerProtocol protocol() const
Returns the network layer protocol of the host address.
void bytesWritten(qint64 bytes)
This signal is emitted every time a payload of data has been written to the device's current write ch...
The QNetworkDatagram class provides the data and metadata of a UDP datagram.
QHostAddress destinationAddress() const
Returns the destination address associated with this datagram.
int destinationPort() const
Returns the port number of the destination associated with this datagram.
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
QByteArray toLatin1() const &
bool ensureInitialized(const QHostAddress &bindAddress, quint16 bindPort)
bool ensureInitialized(const QHostAddress &remoteAddress)
bool leaveMulticastGroup(const QHostAddress &groupAddress)
bool joinMulticastGroup(const QHostAddress &groupAddress)
QNetworkDatagram receiveDatagram(qint64 maxSize=-1)
QNetworkInterface multicastInterface() const
bool hasPendingDatagrams() const
Returns true if at least one datagram is waiting to be read; otherwise returns false.
virtual ~QUdpSocket()
Destroys the socket, closing the connection if necessary.
qint64 writeDatagram(const QNetworkDatagram &datagram)
void setMulticastInterface(const QNetworkInterface &iface)
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *host=nullptr, quint16 *port=nullptr)
Receives a datagram no larger than maxSize bytes and stores it in data.
qint64 pendingDatagramSize() const
Returns the size of the first pending UDP datagram.
QUdpSocket(QObject *parent=nullptr)
Creates a QUdpSocket object.
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
static QString header(const QString &name)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLuint64EXT address
#define QT_CHECK_BOUND(function, a)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent