C++ (Qt)void Server::initSocket() { udpSocket = new QUdpSocket(this); udpSocket->bind(QHostAddress::Any, 7755); connect(udpSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams())); } void Server::readPendingDatagrams() { while (udpSocket->hasPendingDatagrams()) { QByteArray datagram; datagram.resize(udpSocket->pendingDatagramSize()); QHostAddress sender; quint16 senderPort; udpSocket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort); udpSocket->writeDatagram(datagram, sender, senderPort); } }