|
@ -7,7 +7,7 @@ UdpSocket::UdpSocket(QObject* parent, quint16 port) : |
|
|
{ |
|
|
{ |
|
|
_socket = new QUdpSocket(this); |
|
|
_socket = new QUdpSocket(this); |
|
|
_socket->bind(QHostAddress::LocalHost, port); |
|
|
_socket->bind(QHostAddress::LocalHost, port); |
|
|
connect(_socket, SIGNAL(readyRead()), this, SLOT(readyRead())); |
|
|
connect(_socket, &QUdpSocket::readyRead, this, &UdpSocket::readyRead); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
UdpSocket::~UdpSocket() |
|
|
UdpSocket::~UdpSocket() |
|
@ -39,8 +39,8 @@ void UdpSocket::readyRead() |
|
|
{ |
|
|
{ |
|
|
QByteArray Buffer; |
|
|
QByteArray Buffer; |
|
|
Buffer.resize(_socket->pendingDatagramSize()); |
|
|
Buffer.resize(_socket->pendingDatagramSize()); |
|
|
QHostAddress sender_addr{}; |
|
|
QHostAddress sender_addr; |
|
|
quint16 sender_port{}; |
|
|
quint16 sender_port; |
|
|
_socket->readDatagram(Buffer.data(), Buffer.size(), &sender_addr, &sender_port); |
|
|
_socket->readDatagram(Buffer.data(), Buffer.size(), &sender_addr, &sender_port); |
|
|
|
|
|
|
|
|
qDebug() << "New Message arrived at" << getTime(); |
|
|
qDebug() << "New Message arrived at" << getTime(); |
|
|