Aditya Sihag
Aditya Sihag

Reputation: 5167

boost asio read / receive endianess

Reading data over a socket using boost asio tcp read functions or udp receive functions into a

 std::vector<char>, 

does the data fill up the vector in network byte order or receiving-host byte order ?

Upvotes: 3

Views: 2177

Answers (1)

Mike Seymour
Mike Seymour

Reputation: 254661

You will receive the bytes in the same order they were sent.

"Endianness" only has a meaning when dealing with multi-byte numerical values - there are no such things when the message is regarded as a stream or packet of bytes as it is at the TCP/UDP transport layer.

If some of the bytes need to be interpreted as multi-byte values, then you'll need to know how they were encoded by the application layer. Neither TCP nor UDP sockets can help you with that.

Upvotes: 7

Related Questions