I recommend looking at the wired protocol for the Majordomo protocol . This example shows that each βfieldβ in the structure is sent as a separate frame. This works very well and is well supported.
You can also define a byte layout and send your data as a single frame. You will need to solve any problems with endian (if you use the code on platforms that are small and large), but this is quite easy to handle. If you do not know how to do this, use a frame technique, for example, Majordomo.
There will be little performance between using a frame and multiple frames. If you don't send gigabits per second, this is unlikely to be a problem. As always, a guideline for measuring your specific case before you βoptimizeβ and spend a ton of time and effort saving 200 nanoseconds per message.
source share