01-05-2018 06:37 AM
Hello,
I want to know how I can tranfer various data through TCP protocol.
In the picture, I tranfer target to host the add of two number, imagine that I want to do the rest of theese number and tranfer the solution, how can i do?
Have i established a new communication? One communication for each data? or is there any way to tranfer multiple data in one communication?
Thanks so much.
Solved! Go to Solution.
01-05-2018 06:58 AM
Hi Cristina,
you can put into the message whatever you like: either just one number or a whole array of numbers. It's up to you!
You should read about efficient data structures: creating some kind of "structure" in your data will help you with each communication…
01-05-2018 08:04 AM
Hi Cristina
We like to use the Flatten To String, at the sender end, and Unflatten From String, at the receiver end, to package and un-package string data. You can flatten (and unflatten) multiple different data types into one string. We like to use clusters (type defined) as they are good from a readability and scalability standpoint. e.g.
We usually include a Destination (or similar) parameter in our data that allows the sender to define where, in the receiving application, the message should go and also gives us a convenient way to switch when the data arrives. e.g.
Hope this helps
Steve
01-05-2018 08:51 AM
I generally include a very basic header to all of my messages. It makes communication much more versatile as well as expandable. The most basic message header would include two pieces of information. The first piece is a message ID. This indicates the type of message being sent. This allows the other side to take the appropriate action when it receives the message as well as know how to decide it. The second piece I include is length of the message data. I generally use integers for each value. This way the receiver reads a fixed number of bytes, 8 if both are 32-bit values. The first lets the receiver know what type of message is being received and the send will let it know how much more data needs to be read. This is a very efficient method. It also makes it very easy to add new messages as the application grows.
01-05-2018 10:12 AM
@Mark_Yedinak wrote:
I generally include a very basic header to all of my messages. It makes communication much more versatile as well as expandable. The most basic message header would include two pieces of information. The first piece is a message ID. This indicates the type of message being sent. This allows the other side to take the appropriate action when it receives the message as well as know how to decide it. The second piece I include is length of the message data. I generally use integers for each value. This way the receiver reads a fixed number of bytes, 8 if both are 32-bit values. The first lets the receiver know what type of message is being received and the send will let it know how much more data needs to be read. This is a very efficient method. It also makes it very easy to add new messages as the application grows.
I just use the STM library and that takes care of all of that for me.
As far as the actual data, I am a HUGE fan of the Flatten To String and Unflatten From String. What makes these functions better is you can specify the byte order, which can matter a lot depending on what you are communicating with.
01-05-2018 10:48 AM
@crossrulz wrote:
@Mark_Yedinak wrote:
I generally include a very basic header to all of my messages. It makes communication much more versatile as well as expandable. The most basic message header would include two pieces of information. The first piece is a message ID. This indicates the type of message being sent. This allows the other side to take the appropriate action when it receives the message as well as know how to decide it. The second piece I include is length of the message data. I generally use integers for each value. This way the receiver reads a fixed number of bytes, 8 if both are 32-bit values. The first lets the receiver know what type of message is being received and the send will let it know how much more data needs to be read. This is a very efficient method. It also makes it very easy to add new messages as the application grows.
I just use the STM library and that takes care of all of that for me.
As far as the actual data, I am a HUGE fan of the Flatten To String and Unflatten From String. What makes these functions better is you can specify the byte order, which can matter a lot depending on what you are communicating with.
I have to maintain the ability to communicate with components written in other languages so I try to keep a very language agnostic approach.
I am also a big fan of flatten/unflatten as well. While variants are very useful internally when working with other languages they are not workable at all.
01-08-2018 02:08 AM
Thanks so much, I got my goal with your solution.
01-08-2018 05:05 AM
Sorry, another question.
If i want to tranfer a control, how can i do this? because , I'm trying to do this with the solution that you gave me, but it's not valid to transfer control.
Thanks.
01-08-2018 05:24 AM
What properties (value, Label text, Description text etc.) of your control do you want to transfer?
01-08-2018 05:27 AM
I want transfer de value of my controls, almost all my controls are dbl type, except 2 that they are u8 type.
Thanks.