I have a very large (>1 million elements) std::vector that I need to send between two processes using TCP sockets. The reason I'm using std::vector is because I would rather send true and false across as single bits instead of taking up a whole byte (since the data size is so large).
I'm doing some small test cases so that I'm not limited by the maximum transfer size of TCP until I know that everything is working. Essentially, what I'm doing is
int vec[bits->size()];
copy(bits->begin(), bits->end(), vec);
so that it can be sent across the socket. Clearly, something isn't working. If vec contains 1 0 1 0 1 0 1, I receive 1000 0000 1000 0000 1000 0000 1000.
It's obviously expanding the bit vector in the copy. My question is this: how do I reinterpret the bit vector as something that can be sent over the socket, while keeping the size limitations of the original vector?
int vec[bits->size()];Is this variable-sized array? What is type of bits? - Neil Kirkbitsin your question. Please ensure that the code snippet you post actually compiles. - Yakk - Adam Nevraumont