I am using boost ASIO to send message over TCP stream. I send the body size first in strictly 4 bytes length. Than on server side I make a vector<char>
which I resize to 4 bytes and I put the message body size there.
Here is how I convert vector of char std::vector<char> size;
to int:
_packet.body_size = static_cast<int>(_packet.size[0]);
This scenario works when the value which is kept inside _packet.size[0]
is not bigger of 124.
And in this scenario works. body_size
is set to 124
as you can see.
However if the value gets bigger than 124
like 128
for example I am not able to parse it correctly in the same way as I did with 124
.
Take a look:
See to what number is set body_size
. Why am I not able to convert bigger than 124 numbers?
Where is mistake and how can I fix it?