Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. UdpConnection::UdpConnection(QObject* parent)
  2. {
  3. fpgaConnection = QSharedPointer<QUdpSocket>(new QUdpSocket);
  4.  
  5. qDebug() << connect(fpgaConnection.data(), &QUdpSocket::readyRead, this, &FPGA_HardwareInterface::readyRead);
  6.  
  7. if (fpgaConnection->bind(QHostAddress("192.168.10.10"), 1919))
  8. {
  9. qDebug() << "Successfully Bound!";
  10. }
  11. else
  12. {
  13. qDebug() << "BINDING FAILURE";
  14. }
  15.  
  16. fpgaConnection->connectToHost(QHostAddress("192.168.10.200"), 1920);
  17. }
  18.  
  19. void UdpConnection::readyRead()
  20. {
  21. while (fpgaConnection->hasPendingDatagrams())
  22. {
  23. QByteArray buffer;
  24. buffer.resize(fpgaConnection->pendingDatagramSize());
  25.  
  26. QHostAddress sender;
  27. quint16 senderPort;
  28.  
  29. fpgaConnection->readDatagram(buffer.data(), buffer.size(), &sender, &senderPort);
  30. qDebug() << "Message from:" << sender;
  31. qDebug() << "Message port:" << senderPort;
  32. qDebug() << buffer;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement