cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

can you please explain this code (TCP/IP)

can you please explain this code (TCP/IP)

I'm reading someone else's code. Can someone kindly please explain the section send command to server . thank you

0 Kudos
Message 1 of 2
(378 Views)

Re: can you please explain this code (TCP/IP)

Well, the only thing you can send is a raw string and this section of code is used to built that string in a way the receiver expect it to be structured.

 

This code will blow up if the string length of the ringtext.text +8 is larger than the range of U8, so I would probably replace the upper part by just casting the size to a string (it will be 4 bytes directly). So, after the size you are appending four more fixed bytes followed by the text from the property node.

 

So the final string will be structured as follows

  1. data size (4 bytes)
  2. four more bytes (always 0001)
  3. String containing the text

(the total data size is "String size + 8": 4bytes+4bytes+string)

 

Most likely, the receiver will read four bytes to determine the size of the rest of the data, then read that. It then will check if the four next bytes are 0001 (e.g. a custom tag, telling the receiver what the data represents: 0001="text of a ring", 0002="array data", etc.) Smiley Very Happy), then extract the real payload, the text and send it to the rest of the code for processing.

 


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 2 of 2
(369 Views)