Hello Carson.
I think there is a mistake in the usage of the iostream element of the BLOB. The iostream is used to lock the BLOB and open/close the corresponding file descriptor. You need to create an iostream object for the whole time you are working with the stream. In your code you create and destroy the stream in the same operation.
This code is not tested, but something like that should work:
ibrcommon::BLOB::Reference ref = ibrcommon::BLOB::create(); ibrcommon::BLOB::iostream ios = ref.iostream(); dtn::data::DefaultSerializer serializer(*ios);
try { // activate exceptions for this method if (!ios->good()) throw ibrcommon::IOException("stream went bad"); serializer << (bundle); // flush the stream (*ios) << std::flush;
} catch (const ibrcommon::Exception &ex) { IBRCOMMON_LOGGER_DEBUG(10) << ex.what() << IBRCOMMON_LOGGER_ENDL; throw; }
Kind regards, Johannes
Am 27.08.2012 22:00, schrieb Carson Dunbar:
u_int32_t NCRoutingExtension::generate_and_enqueue_encodings(dtn::data::Bundle bundle, u_int32_t max_chunk_size) { // start with just the standard basis, i.e. fragmentation
// need to figure out the number of chunks that will be created // still requiring the number of chunks to be a multiple of 8? // let's try to not require it // dtn::core::BundleStorage &storage = (**this).getStorage(); u_int32_t num_chunks, chunk_size;
size_t orig_bundle_len = 0; size_t block_len; ibrcommon::BLOB::Reference ref = ibrcommon::BLOB::create(); dtn::data::DefaultSerializer serializer(*ref.iostream()); try { // activate exceptions for this method if (!ref.iostream()->good()) throw ibrcommon::IOException("stream went bad"); serializer << (bundle); // flush the stream (*ref.iostream()) << std::flush;
} catch (const ibrcommon::Exception &ex) { IBRCOMMON_LOGGER_DEBUG(10) << ex.what() << IBRCOMMON_LOGGER_ENDL; throw; }