I have one server and several clients which have different functions (e.g. to communicate result of data detection, to , I need to define communication protocol to exchange information in C Ansi.
Both Clients and Server can start communication and messages has variable length.
I think to create protocol in this way:
1st message which will contain 2 info:
  • code which defines who is starting communication e what kind of data is containing
  • length of next message of data content


Of course I'll know how data will be formatted and interpreted inside 2nd message.

I thought to handle with only one message but I should have to define fixed length of message so It's not applicable.
What so you think?