0
  • I have a QTCPServer receiver that is receiving different streams of data
  • Each QDataStream is received at fixed intervals i.e. 10 Hz and 1Hz
  • Out of all these data streams, two streams are received at same 10Hz rate

Issue: Since dataRate is the same on sending side, every time one of the stream is missed at receiving side.

It is just a sample code so please ignore typos or syntax errors. Sender Side :

timer1.setInterval(1000) with Message_Id = 1
timer2.setInterval(100) with Message_Id = 2
timer3.setInterval(100) with Message_Id = 3

//data is sent in the timer Handlder
//data is sent successfully and cross-checked

Receiver Side:

QByteArray array;
QDataStream stream(&array:QIODevice:ReadOnly)
array = tcpServerConnection->readAll()

MyMessageType message;
stream >> message;

switch(message.id){
case 1:{
  MessageType1 message1;
  stream >> message1;}
  break;
case 2:{
  MessageType2 message2;
  stream >> message2;}
  break;
case 3:{
  MessageType3 message3;
  stream >> message3;}
  break;}}

So in this case, if Message2 and Message3 have the same timer intervals, only one of them is received. Individually every message is received just fine.

Also with different random intervals, each message is received just fine.

What can be the issue with the same time intervals when sending a Qdatastream?

taimoor1990
  • 158
  • 1
  • 13
  • 3
    Sounds like concatenation of messages. Even if you send 2 messages separately in the same socket receiver can read it as one big (concatenated) message. In this case you don't loose bytes but you interpret 2 messages as one on receiver side – Serhiy Kulish Sep 30 '21 at 09:29
  • It may depend from how you receive messages and process them. May be when you process a message your process is blocked, and if at the moment another message comes you don't process it at all. – vahancho Sep 30 '21 at 09:41
  • `Wireshark` or `tcpdump` should help to see if it's your sender or receiver side has problem – tunglt Oct 01 '21 at 07:23

0 Answers0