c++ - Reading binary data in memory into a stringstream and stream this over a socket -
i know if possible to, instance, take piece of data in memory, read output stringstream (as binary data) , write onto socket client application process.
the problem run while attempting following:
example:
char name[1024] = "test"; std::ostringstream message (std::stringstream::out | std::stringstream::binary); len = strlen(name); message.write(reinterpret_cast<const char*>(&len), sizeof(int)); message.write(test, len*sizeof(char));
i want write stringstream socket of data in it, problem this: stringstream write executes first time, in case writing 4 (the length of string) , none of subsequent writes. missing here?
if not best way it, best way accomplish this? partly reduce file i/o cached memory snapshots.
thanks in advance..
your code (with minor fixes) appears work me, might check sure correctly handling buffered binary data, i.e. not assume std::string
contains string.
Comments
Post a Comment