Hi guys,
I'm relatively new to C++ and have never worked with serialization so I am very much out of my programming comfort zone here, and been at this for a day with minimal progress.
So here is what I am trying to work towards. I want to send various structs containing data between the client and server programs. The connection is using TCP, and I am using the boost package and my code is completely based (for now) on the serialization example: here.
The issue is that I need to have multiple different types of messages (structs) not just one which they have in the example, so I am trying to find a way to identify the message so I know which struct to use when deserializing it. My original plan was to have the first variable be a unique id for the struct, so it could identify the struct and deserialize accordingly. But unfortunately, it looks like boost just deserializes the whole struct in one go.
I searched for a solution online to no avail, which must mean the solution is so simple that no-one has found the need to ask. The most annoying part of this is that my structs are so simple; consisting of a few char arrays and ints. Any suggestions will be appreciated.
I'm relatively new to C++ and have never worked with serialization so I am very much out of my programming comfort zone here, and been at this for a day with minimal progress.
So here is what I am trying to work towards. I want to send various structs containing data between the client and server programs. The connection is using TCP, and I am using the boost package and my code is completely based (for now) on the serialization example: here.
The issue is that I need to have multiple different types of messages (structs) not just one which they have in the example, so I am trying to find a way to identify the message so I know which struct to use when deserializing it. My original plan was to have the first variable be a unique id for the struct, so it could identify the struct and deserialize accordingly. But unfortunately, it looks like boost just deserializes the whole struct in one go.
I searched for a solution online to no avail, which must mean the solution is so simple that no-one has found the need to ask. The most annoying part of this is that my structs are so simple; consisting of a few char arrays and ints. Any suggestions will be appreciated.