#include "udpserver.h" #include #include #define UDP_IMAGE_PORT 4242 UdpLedServer ::UdpLedServer (QObject *parent) : QObject(parent) { initSocket(); } void UdpLedServer ::initSocket() { this->mUdpSocket = new QUdpSocket(this); this->mUdpSocket->bind(QHostAddress::LocalHost, UDP_IMAGE_PORT); connect(this->mUdpSocket, &QUdpSocket::readyRead, this, &UdpLedServer ::readPendingDatagrams); } void UdpLedServer ::readPendingDatagrams() { while (this->mUdpSocket->hasPendingDatagrams()) { QNetworkDatagram datagram = this->mUdpSocket->receiveDatagram(); processTheDatagram(datagram); } } void UdpLedServer::processTheDatagram(QNetworkDatagram datagram) { if (datagram.isValid()) { qDebug() << "Received datagram:" << datagram.data().size(); } }