I am currently writing a server in C++ and an Android app that revceives data from it using google protobuf. Currently I frame the data with the size, so basically I send
-----------------------------------------------------
| payload size (4byte, unsigned) | protobuf payload |
-----------------------------------------------------
I have no problem deserializing the stuff in Java, but how can I convert the bytes from the socket to an unsigned integer? The payload size
is always a uint32_t
that has been converted with htonl
to network byte order. So Java needs to convert to host byte order and convert it to an Integer.