I want to write (for the sake of learning) how to write a client-server app using C++. I have actually done it in the past and found many excellent tutorials on the web, including this good post on stack overflow:
How to write Client-Server application and implement simple protocol in Qt
What I would like to learn this time (and better understand) is how to actually write a protocol to communicate "meaningful" data between the client and server. Most examples just pass strings such as "Hello world". Great but not very practical.
What I would like to do is pass for example commands to the server that would modify some data (a document that the server would for example be responsible of keeping a copy of). I have been inspired after watching a video on Google Drive Real-Time in which they explain how the clients send commands like [insert, 10, "caterpillar"]
to the server, which has for effect for example, to insert the chain of character "caterpillar" at index 10 in a string maintained by the server.
How would you send such commands typically in professional applications (how do you define them in the code, how do you pass them on, how to read them on the other end?)?
Bonus question;-): the video speaks a lot about data model. How does it relate to the protocol (the commands exchanged between the client and server and that allow them to understand each other)?
EDIT:
Actually found this question on Stackoverflow with some helpful answers:
Passing a structure through Sockets in C
What's the best way to serialize data in a language-independent binary format?
The solution seems to be called serialisation.