/* # Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING # # If you have any feedback please consult http://openslx.org/feedback and # send your suggestions, praise, or complaints to feedback@openslx.org # # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # src/net/mcast/trial_programs/mcastsend.cpp # - Send a file via the PVS Mcast protocol # ----------------------------------------------------------------------------- */ #include #include #include #include #include #include #include "mcastsend.h" #include "McastConfigArgParser.h" #include "../McastConstants.h" #include "../McastConfiguration.h" using namespace std; int main(int argc, char**argv) { QCoreApplication app(argc, argv); McastSend me; QTimer::singleShot(0, &me, SLOT(run())); return app.exec(); } void McastSend::run() { QStringList args = QCoreApplication::arguments(); QStringList::iterator i = args.begin(); QStringList::iterator const end = args.end(); QString filename(""); McastConfiguration config; ++i; while(i != end) { // parse command line arguments QString arg = *i; cerr << "Arg: " << arg.toLatin1().constData() << endl; if (arg == "-file") { i++; if(i == end) { cerr << "Option " << arg.toLatin1().constData() << " is missing argument" << endl; QCoreApplication::exit(1); return; } filename = *i; } else if (arg == "-help") { cerr << "Options:" << endl << endl << " -file Send FILE to the listeners" << endl << " -addr Use ADDR as address specification" << endl << " -dport Send to port PORT" << endl << " -sport Send from port PORT" << endl << " -mtu Set MTU to BYTES" << endl << " -rate Send BYTES per second" << endl << " -winsize Set Window Size to SECONDS" << endl << " -udp Use UDP encapsulation" << endl << " -udp-port PORT Use UDP port PORT" << endl; QCoreApplication::quit(); return; } else { if (!parseMcastConfigArg(i, end, &config)) { cerr << "Unknown command line argument: " << arg.toLatin1().constData() << endl; QCoreApplication::exit(1); return; } } ++i; } if(filename == "") { cerr << "No filename given" << endl; QCoreApplication::exit(1); return; } // now, do it. QFile* file = new QFile(filename); file->open(QIODevice::ReadOnly); McastSender* sender = new McastSender(file, &config, this); file->setParent(sender); connect(sender, SIGNAL(finished()), this, SLOT(finished())); QTimer::singleShot(0, sender, SLOT(start())); } void McastSend::finished() { cerr << "finished." << endl; // QTimer::singleShot(30000, QCoreApplication::instance(), SLOT(quit())); // QCoreApplication::quit(); }