All I have found until now about receiving data with sockets (recv
) is in plain old C.
And even if it's C++, it's either receiving byte-by-byte on a std::vector<char>
(eww!), or defining a static size (e.g. vec.resize(BIG_NUMBER)
), and then receiving.
However, all of that seems very inefficient and / or ugly, so I was wondering, what's the most efficient, correct, and elegant way of doing it in C++? (not C)
A good example of where'd somebody need to receive an unknown amount of data is a web browser. (ignoring the Content-length
header for the sake of the example)