uint32_t value = 123456789; boost::asio::streambuf buffer; std::ostream output_stream(&buffer); boost::asio::write(output_stream, boost::asio::buffer(&value, sizeof(value)));
uint32_t value = 987654321; std::ofstream output_file("file.bin", std::ios::binary); boost::asio::streambuf buffer; std::ostream output_stream(&buffer); boost::asio::write(output_stream, boost::asio::buffer(&value, sizeof(value))); output_file.write(boost::asio::buffer_castIn both of these examples, we create a stream buffer and an output stream that points to that buffer. We then use the "out_uint32_le" function to output the unsigned integer to the stream using the "boost::asio::write" function. In the first example, we output the value over a network connection, and in the second example, we store the value in a file.(buffer.data()), buffer.size());