LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String order - TCP

Good Morning,  

I expose my problem:  

 

I transmit a string beetwen TCP (TCP Write), but when I read this string (TCP Read) it is not always in the same order as it was sent, sometimes yes, sometimes not, how can I read the string exactly? in the same order that was sent?  

 

Thank you.   A greeting

0 Kudos
Message 1 of 18
(3,221 Views)

Hi Cristina,

 

can you attach a VI demonstrating that behaviour?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 18
(3,193 Views)

You need to explain in more detail what you are doing. TCP is a stream based protocol and one of its guarantees is that the data arrives in the same order as it was sent. If that does not appear so you have probably a race condition in your sender where you try to send from different locations in parallel through the same connection refnum and while you think you enforce a specific order you don't since LabVIEW is happily executing code that has no data flow dependency in parallel with each other and then it is pure randomness which function is scheduled earlier. You may think that if you single step through the code there only is always the one code function executing but that is because LabVIEW has to sequentially highlight the functions since humans are pretty bad to interpret multiple things happening in parallel. When you disable single stepping LabVIEW executes the code again with full speed and not necessarily in the same order as what you saw in single step mode debugging.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 18
(3,191 Views)

That's not normal behaviour. Must be something you're doing.

 

Do you send one string (e.g. one send)? Or 

Do you send the string from multiple parallel loops?

 

Some code would help.

0 Kudos
Message 4 of 18
(3,189 Views)

Hello,

 

firstly thanks to answer.

 

I'm attaching a image of program, I'm communicating my computer with a sb-rio

 

 

Thanks.

 

 

0 Kudos
Message 5 of 18
(3,179 Views)

Hi Cristina,

 

are you sure you ALWAYS send/receive just 4 bytes?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 18
(3,174 Views)

can it be that you still have something in the buffer from "before"?

so you get the "0" from an earlier send as first char of your 4?


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 18
(3,166 Views)

The string is composed from 2W00 or 2W02 or 2W10 or 2W11 

 

This is 4 byte , not?

 

 

0 Kudos
Message 8 of 18
(3,162 Views)

I thought so , but  I don't know how can i check this.

 

Do you know?

0 Kudos
Message 9 of 18
(3,161 Views)

Or how i can clean the buffer?

 

0 Kudos
Message 10 of 18
(3,154 Views)