typedef unsigned int uint;struct MyStruct { timeval sTimeStamp; uint ID;}; QByteArray *block = new QByteArray; QDataStream out(block, QIODevice::WriteOnly); out.setVersion(QDataStream::Qt_4_8); out.setByteOrder(QDataStream::BigEndian); out.setFloatingPointPrecision(QDataStream::SinglePrecision); MyStruct *msg = new MyStruct(); memset(msg, 1, sizeof(MyStruct)); msg->ID = 0; out << msg->ID; udpSocket->writeDatagram(block->data(), block->size(), adr, 778);
qDebug() << "socket data recieved: " << pUdpSocket->size() << " bytes"; QByteArray *datagram = new QByteArray(pUdpSocket->pendingDatagramSize(), '0'); do { //datagram.resize(pUdpSocket->pendingDatagramSize()); pUdpSocket->readDatagram(datagram->data(), pUdpSocket->pendingDatagramSize()); } while (pUdpSocket->hasPendingDatagrams()); QDataStream in(datagram, QIODevice::ReadOnly); in.setVersion(QDataStream::Qt_4_8); in.setByteOrder(QDataStream::BigEndian); in.setFloatingPointPrecision(QDataStream::SinglePrecision); MyStruct *msg = new MyStruct(); memset(msg, 0, sizeof(MyStruct)); in >> msg->ID; evLoop->exit();
QByteArray *datagram = new QByteArray(pUdpSocket->pendingDatagramSize(), '0'); do { //datagram.resize(pUdpSocket->pendingDatagramSize()); pUdpSocket->readDatagram(datagram->data(), pUdpSocket->pendingDatagramSize()); } while (pUdpSocket->hasPendingDatagrams()); QDataStream in(datagram, QIODevice::ReadOnly);
QByteArray socketData; socketData.resize(pUdpSocket->pendingDatagramSize()); pUdpSocket->readDatagram(socketData.data(), socketData.size()); QDataStream in(&socketData, QIODevice::ReadOnly);
QByteArray *datagram = new QByteArray(pUdpSocket->pendingDatagramSize(), '0');
QByteArray *datagram = new QByteArray(pUdpSocket->pendingDatagramSize(), 0);
socket data recieved: 1 bytes datagramm: 1 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 3 bytes datagramm: 3 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 4 bytes datagramm: 4 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 2 bytes datagramm: 2 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 2 bytes datagramm: 2 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 3 bytes datagramm: 3 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 3 bytes datagramm: 3 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 3 bytes datagramm: 3 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 3 bytes datagramm: 3 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 5 bytes datagramm: 5 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 5 bytes datagramm: 5 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 5 bytes datagramm: 5 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 7 bytes datagramm: 7 socket data recieved: 86 bytes datagramm: 86 socket data recieved: 7 bytes datagramm: 7
sent 0 sent 1.8 get: 0 sent 36 sent 72 get: 0 sent 106.2 sent 142.2 get: 0 sent 176.4 sent 210.6 get: 0 sent 244.8 sent 279 get: 0 sent 313.2 sent 349.2 get: 0 sent 23.3996 sent 61.1996 get: 1.8 sent 95.3996 sent 131.4 get: 36 sent 165.6 sent 199.8 get: 72 sent 235.8 sent 270 get: 106.2 sent 304.2 sent 340.199 get: 142.2 sent 16.1992 sent 52.1992 get: 176.4 sent 89.9992 sent 124.199 get: 210.6 sent 158.399 sent 192.599 get: 244.8 sent 226.799 sent 264.599 get: 279 sent 298.799 sent 331.199 get: 313.2 sent 3.5988 sent 37.7988 get: 349.2 sent 71.9988 sent 106.199 get: 23.3996 sent 140.399 sent 176.399 get: 61.1996 sent 210.599 sent 244.799 get: 95.3996 sent 280.799 sent 307.799 get: 131.4 sent 336.599 sent 10.7984 get: 165.6 sent 46.7984 sent 82.7984 get: 199.8 sent 116.998 sent 151.199 get: 235.8 sent 187.199 sent 224.999 get: 270 sent 259.199