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
qudpsocket.h
Go to the documentation of this file.
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
4#ifndef QUDPSOCKET_H
5#define QUDPSOCKET_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtNetwork/qabstractsocket.h>
9#include <QtNetwork/qhostaddress.h>
10
12
13
14#ifndef QT_NO_UDPSOCKET
15
19
20class Q_NETWORK_EXPORT QUdpSocket : public QAbstractSocket
21{
23public:
24 explicit QUdpSocket(QObject *parent = nullptr);
25 virtual ~QUdpSocket();
26
27#if QT_VERSION < QT_VERSION_CHECK(7,0,0) && !defined(Q_QDOC)
28 // ### Qt7: move into QAbstractSocket
30 bool bind(QHostAddress::SpecialAddress addr, quint16 port = 0, BindMode mode = DefaultForPlatform)
31 { return bind(QHostAddress(addr), port, mode); }
32#endif
33
34#ifndef QT_NO_NETWORKINTERFACE
35 bool joinMulticastGroup(const QHostAddress &groupAddress);
36 bool joinMulticastGroup(const QHostAddress &groupAddress,
37 const QNetworkInterface &iface);
38 bool leaveMulticastGroup(const QHostAddress &groupAddress);
39 bool leaveMulticastGroup(const QHostAddress &groupAddress,
40 const QNetworkInterface &iface);
41
42 QNetworkInterface multicastInterface() const;
43 void setMulticastInterface(const QNetworkInterface &iface);
44#endif
45
46 bool hasPendingDatagrams() const;
47 qint64 pendingDatagramSize() const;
48 QNetworkDatagram receiveDatagram(qint64 maxSize = -1);
49 qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *host = nullptr, quint16 *port = nullptr);
50
51 qint64 writeDatagram(const QNetworkDatagram &datagram);
52 qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &host, quint16 port);
53 inline qint64 writeDatagram(const QByteArray &datagram, const QHostAddress &host, quint16 port)
54 { return writeDatagram(datagram.constData(), datagram.size(), host, port); }
55
56private:
57 Q_DISABLE_COPY_MOVE(QUdpSocket)
58 Q_DECLARE_PRIVATE(QUdpSocket)
59};
60
61#endif // QT_NO_UDPSOCKET
62
64
65#endif // QUDPSOCKET_H
The QAbstractSocket class provides the base functionality common to all socket types.
virtual bool bind(const QHostAddress &address, quint16 port=0, BindMode mode=DefaultForPlatform)
\inmodule QtCore
Definition qbytearray.h:57
The QHostAddress class provides an IP address.
SpecialAddress
\value Null The null address object.
The QNetworkDatagram class provides the data and metadata of a UDP datagram.
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces.
\inmodule QtCore
Definition qobject.h:103
\reentrant
Definition qudpsocket.h:21
qint64 writeDatagram(const QByteArray &datagram, const QHostAddress &host, quint16 port)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qudpsocket.h:53
Combined button and popup list for selecting options.
EGLOutputPortEXT port
GLenum mode
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum const void * addr
GLenum GLsizei len
#define Q_OBJECT
unsigned short quint16
Definition qtypes.h:48
long long qint64
Definition qtypes.h:60
udpSocket writeDatagram(std::move(datagram).makeReply(replyData))
[0]
socketLayer bind(QHostAddress::Any, 4000)
serverSocket readDatagram(clientHello.data(), clientHello.size(), &address, &port)