24 #include <ibrcommon/net/socket.h>
25 #include <ibrcommon/thread/Mutex.h>
26 #include <ibrcommon/thread/MutexLock.h>
27 #include <ibrcommon/thread/SignalHandler.h>
30 #include <ibrcommon/data/BLOB.h>
31 #include <ibrcommon/data/File.h>
32 #include <ibrcommon/appstreambuf.h>
38 #include <sys/types.h>
54 {
"workdir", required_argument, 0,
'w'},
55 {
"quiet", no_argument, 0,
'q'},
61 std::cout <<
"-- dtninbox (IBR-DTN) --" << std::endl;
62 std::cout <<
"Syntax: dtninbox [options] <name> <inbox>" << std::endl;
63 std::cout <<
" <name> The application name" << std::endl;
64 std::cout <<
" <inbox> Directory where incoming files should be placed" << std::endl << std::endl;
65 std::cout <<
"* optional parameters *" << std::endl;
66 std::cout <<
" -h|--help Display this text" << std::endl;
67 std::cout <<
" -w|--workdir Temporary work directory" << std::endl;
68 std::cout <<
" --quiet Only print error messages" << std::endl;
77 int c = getopt_long (argc, argv,
"hw:q",
91 printf (
" with arg %s", optarg);
109 if ((argc - optind) < 2)
125 ibrcommon::socketstream *
_conn = NULL;
139 int main(
int argc,
char** argv)
142 ibrcommon::SignalHandler sighandler(
term);
143 sighandler.handle(SIGINT);
144 sighandler.handle(SIGTERM);
150 sighandler.initialize();
156 if (blob_path.exists())
158 ibrcommon::BLOB::changeProvider(
new ibrcommon::FileBLOBProvider(blob_path),
true);
163 unsigned int backoff = 2;
170 ibrcommon::vaddress addr(
"localhost", 4550);
171 ibrcommon::socketstream conn(
new ibrcommon::tcpsocket(addr));
192 std::cout <<
"received bundle: " << b.
toString() << std::endl;
199 ibrcommon::BLOB::iostream stream = ref.iostream();
212 }
catch (
const ibrcommon::socket_exception&) {
218 std::cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << std::endl;
219 ibrcommon::Thread::sleep(backoff * 1000);
225 backoff = backoff * 2;
228 }
catch (
const ibrcommon::IOException&) {
234 std::cout <<
"Connection to bundle daemon failed. Retry in " << backoff <<
" seconds." << std::endl;
235 ibrcommon::Thread::sleep(backoff * 1000);
241 backoff = backoff * 2;
244 }
catch (
const std::exception&) {
250 return (EXIT_SUCCESS);
std::string toString() const
ibrcommon::socketstream * _conn
int main(int argc, char **argv)
static void read(const ibrcommon::File &extract_folder, std::istream &input)
dtn::data::Bundle getBundle(const dtn::data::Timeout timeout=0)
void read_configuration(int argc, char **argv)
struct option long_options[]
ibrcommon::File blob_path("/tmp")
iterator find(block_t blocktype)