Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UdpConnection::UdpConnection(QObject* parent)
- {
- fpgaConnection = QSharedPointer<QUdpSocket>(new QUdpSocket);
- qDebug() << connect(fpgaConnection.data(), &QUdpSocket::readyRead, this, &FPGA_HardwareInterface::readyRead);
- if (fpgaConnection->bind(QHostAddress("192.168.10.10"), 1919))
- {
- qDebug() << "Successfully Bound!";
- }
- else
- {
- qDebug() << "BINDING FAILURE";
- }
- fpgaConnection->connectToHost(QHostAddress("192.168.10.200"), 1920);
- }
- void UdpConnection::readyRead()
- {
- while (fpgaConnection->hasPendingDatagrams())
- {
- QByteArray buffer;
- buffer.resize(fpgaConnection->pendingDatagramSize());
- QHostAddress sender;
- quint16 senderPort;
- fpgaConnection->readDatagram(buffer.data(), buffer.size(), &sender, &senderPort);
- qDebug() << "Message from:" << sender;
- qDebug() << "Message port:" << senderPort;
- qDebug() << buffer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement