I need to create TCP chat with C++ clients and Python server(already started), I have messages in c++ class like
class Message{
public:
uint64 utc_time;
uint64 token;
string content;
};
I am sending this from client to server, on server I have priority queue by utc_time and need to broadcast to others. My question is how to serialize this, which format to use so to avoid any cross language dependencies on size type size ? (maybe is going to be more meta data in future so need kind a little generic) ? Can anyone give me advice which format to use for serialization(or to flush only like bytes) ?
class Persistent:
public:
Persistent(int sz):objSize(sz){}
void write(std::ostream& out)const{out.write((char*)this, objSize);}
void read(std::istream& in){in.read((char*)this, objSize);}
private:
int objSize;
};
I thought of other possibility to have deserializator in c++ on server and call from python if that is possible. Any elegant solution to this problem ?