#include <sstream>
std::ostringstream buffer;
buffer << "a char buffer" << customObject << someOtherObject;
std::string contents = buffer.str();
size_t bufferSize = contents.size();
rawNetworkSocket.Send(contents);
Using this approach, you will have to analyze the result in which you get it (since the code above simply converts your data into an unstructured string.
, ++ , < < . Custom:
template<typename C, typename T>
std::basic_ostream<C,T>& operator << (
std::basic_ostream<C,T>& out, const Custom& object)
{
out << object.member1 << "," << object.member2 << object.memberN;
return out;
}
, boost:: serialization.