Added the function ReadyRead, which accepts datagrams.

This commit is contained in:
ChronosX88 2018-05-12 14:41:55 +03:00
parent d36a361b9a
commit d20b4188aa

View File

@ -25,4 +25,14 @@ class Network
out << qint64(data.size() - sizeof(qint64));
socket->writeDatagram(data, QHostAddress(ip), 6552);
}
void readyRead()
{
QByteArray buffer;
buffer.resize(socket->pendingDatagramSize());
QHostAddress sender;
socket->readDatagram(buffer.data(), buffer.size(),
&sender;, &senderPort;);
qDebug() << "Message from: " << sender.toString();
qDebug() << "Message: " << buffer;
}
}