node+transport: Fixing bug that prevented reconnection to the forwarder after being disconnected for some reason
tools/ndnputcatchunks shows an example how to design a daemon
application that is resilient to the local daemon shutdowns/restarts.
Note that when local forwarder disconnects, all pending interests and
registered prefixes will get flushed.
Change-Id: I2933e2b5d6fd8420de4f055e53c748dbd00cabe9
diff --git a/tools/ndnputchunks.cpp b/tools/ndnputchunks.cpp
index 68755a9..a1d581b 100644
--- a/tools/ndnputchunks.cpp
+++ b/tools/ndnputchunks.cpp
@@ -121,7 +121,19 @@
std::cerr << "Preparing the input..." << std::endl;
Producer producer (argv[1]);
std::cerr << "Ready... (took " << ((ndn::getNow() - time)/1000) << " seconds)" << std::endl;
- producer.run ();
+ while(true)
+ {
+ try
+ {
+ producer.run (); // this will exit when daemon dies... so try to connect again if possible
+ }
+ catch (std::exception& e)
+ {
+ std::cerr << "ERROR: " << e.what () << std::endl;
+ // and keep going
+ sleep (1);
+ }
+ }
}
catch (std::exception& e)
{