21 #include <boost/program_options.hpp>
22 #include <boost/asio.hpp>
27 namespace po = boost::program_options;
29 int main(
int argc,
char* argv[])
32 unsigned int port = 0;
34 po::options_description desc(
"Options");
36 (
"help,h",
"Print this help and exit.")
38 po::value<std::string>(&filename)->required(),
39 "Set the name of the data file to send back to DQ or CLBSwissKnife.")
41 po::value<unsigned int>(&port)->required(),
42 "Set the UDP port to send the data through");
48 po::command_line_parser(argc, argv).
options(desc).run(),
53 std::cout << desc << std::endl;
59 catch (
const po::error& e)
61 std::cerr <<
"CLBReplay: Error: " << e.what() <<
'\n'
65 catch (
const std::runtime_error& e)
67 std::cerr <<
"CLBReplay: Error: " << e.what() <<
'\n'
72 std::ifstream input_file(filename.c_str());
73 boost::asio::ip::udp::udp::endpoint endpoint(
74 boost::asio::ip::address::from_string(
"127.0.0.1"),
77 boost::asio::io_service service;
78 boost::asio::ip::udp::socket sock(service, boost::asio::ip::udp::udp::v4());
82 while (input_file && input_file.peek() != EOF)
84 unsigned int datagram_size = 0;
85 input_file.read((
char*) &datagram_size,
sizeof(datagram_size));
87 input_file.read(buffer, datagram_size);
89 sock.send_to(boost::asio::buffer(buffer, datagram_size), endpoint);
94 std::cout <<
"File finished\n";
int main(int argc, char *argv[])
then usage $script[port]< option > nPossible options
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.