You cannot send that structure that way, when it contains datatype which are not binary copyable.
Here is just one example:
You can convert all the structure data in to char data and then send it
struct message
{
std::string messagedata;
std::string date;
std::string time;
std::string source;
std::string filepath;
}
message msg;
std::string str = msg.messagedata + "," + msg.date + "," + msg.time + "," + msg.source + "," + msg.filepath;
//send bytes
//reveive bytes.
// split it into sub-string
// store is back into struct.
struct message
{
std::string messagedata;
std::string date;
std::string time;
std::string source;
std::string filepath;
}
message msg;
std::string str = msg.messagedata + "," + msg.date + "," + msg.time + "," + msg.source + "," + msg.filepath;
QByteArray bytes(str.c_str(), str.length());
//send bytes
//reveive bytes.
// split it into sub-string
// store is back into struct.
To copy to clipboard, switch view to plain text mode
Bookmarks