Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_network_socket_qudpsocket.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4//! [0]
5void Server::initSocket()
6{
7 udpSocket = new QUdpSocket(this);
8 udpSocket->bind(QHostAddress::LocalHost, 7755);
9
10 connect(udpSocket, &QUdpSocket::readyRead,
11 this, &Server::readPendingDatagrams);
12}
13
14void Server::readPendingDatagrams()
15{
16 while (udpSocket->hasPendingDatagrams()) {
17 QNetworkDatagram datagram = udpSocket->receiveDatagram();
18 processTheDatagram(datagram);
19 }
20}
21//! [0]