Browse Source

Comply with bio standard

master
h-4nd-h 2 years ago
parent
commit
0ef1a5c04f
  1. 6
      socket.cpp
  2. 1
      socket.h

6
socket.cpp

@ -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();

1
socket.h

@ -16,6 +16,7 @@ private:
public: public:
explicit UdpSocket(QObject* parent = nullptr, quint16 port = 1234); explicit UdpSocket(QObject* parent = nullptr, quint16 port = 1234);
~UdpSocket();
void sayHello(); void sayHello();
void sayMsg(QString Msg); void sayMsg(QString Msg);

Loading…
Cancel
Save