path: root/src/network/doc
diff options
authorThiago Macieira <>2015-03-10 16:22:24 -0700
committerThiago Macieira <>2016-06-20 16:11:35 +0000
commit4da2dda2aa1f710177157dc1cf841e0bf0b9d829 (patch)
treeb1a28c4773c0d2f16537b6dee82ec8e944337269 /src/network/doc
parent3aaa5d6b32130d3eeac872a59a5a44bfb20dfd4a (diff)
Long live QNetworkDatagram!
This commit adds a new class called QNetworkDatagram that encapsulates the IP packet header and UDP/IP stack metadata along with the actual payload data. It can be used for both receiving as well as sending data. It's called QNetworkDatagram so it can be used by QSctpSocket too, when that lands. [ChangeLog][QtNetwork] Added QNetworkDatagram class, along with new function receiveDatagram in QUdpSocket that returns it and an overload to writeDatagram that can accept it. Change-Id: Iee8cbc07c4434ce9b560ffff13ca467f425ddc3d Reviewed-by: Alex Trotsenko <> Reviewed-by: Richard J. Moore <>
Diffstat (limited to 'src/network/doc')
1 files changed, 1 insertions, 8 deletions
diff --git a/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp b/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp
index 9e491f802e..a98e31b10b 100644
--- a/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp
+++ b/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp
@@ -61,14 +61,7 @@ void Server::initSocket()
void Server::readPendingDatagrams()
while (udpSocket->hasPendingDatagrams()) {
- QByteArray datagram;
- datagram.resize(udpSocket->pendingDatagramSize());
- QHostAddress sender;
- quint16 senderPort;
- udpSocket->readDatagram(, datagram.size(),
- &sender, &senderPort);
+ QNetworkDatagram datagram = udpSocket->receiveDatagram();