简体   繁体   中英

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM