From 00ab2cf6add2976b3a4e8f8cc488777ad5c27808 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Fri, 26 Aug 2016 11:21:41 +0200 Subject: Initial commit, just some ideas and testing. --- network-handler/main.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 network-handler/main.cpp (limited to 'network-handler/main.cpp') diff --git a/network-handler/main.cpp b/network-handler/main.cpp new file mode 100644 index 0000000..128c0e8 --- /dev/null +++ b/network-handler/main.cpp @@ -0,0 +1,42 @@ + +#include "networkhandler.hpp" + +#include + +#include +#include +#include + +int main(int argc, char* argv[]) { + namespace po = boost::program_options; + + po::options_description desc("Allowed options"); + desc.add_options() + ("help,h", "produce help message") + ("port,p", po::value()->default_value(9200), "Set listening port") + ("enable_v4", po::value()->default_value(true), "Enable/disable ipv4 accept support") + ("interface4,4", po::value()->default_value("0.0.0.0"), "Set the ipv4 address to listen on.") + ("enable_v6", po::value()->default_value(true), "Enable/disable ipv6 accept support") + ("interface6,6", po::value()->default_value("::"), "Set the ipv6 address to listen on") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 0; + } + + bool en4 = vm["enable_v4"].as(); + std::string if4 = vm["interface4"].as(); + bool en6 = vm["enable_v6"].as(); + std::string if6 = vm["interface6"].as(); + uint16_t port = vm["port"].as(); + + ListenSettings lsettings{en4, if4, en6, if6, port}; + + NetworkHandler handler(lsettings); + handler.run(); +} -- cgit v1.2.3-70-g09d2