#include <csignal>
#include <thread>
#include <iostream>
#include <modbuspp.h>
using namespace std;
void
sighandler (int sig) {
cout << "everything was closed." << endl << "Have a nice day !" << endl;
exit (EXIT_SUCCESS);
}
int main (int argc, char **argv) {
if (argc < 2) {
cerr << "Error: the JSON filename must be provided as a parameter on the command line !" << endl;
cerr << "e.g. : " << argv[0] << " virtual-server-tcp.json" << endl;
exit (EXIT_FAILURE);
}
string jsonfile = argv[1];
cout << "Simple Server" << endl;
signal (SIGINT, sighandler);
signal (SIGTERM, sighandler);
cout << "Press CTRL+C to stop... " << endl << endl;
try {
cout << "opening " << jsonfile << "..." << endl;
cout << "Listening server on " <<
std::this_thread::sleep_for (std::chrono::milliseconds (200));
}
}
}
catch (std::exception & e) {
cerr << "Error: " << e.what() << endl;
}
catch (...) {
cerr << "Unattended exception !" << endl;
}
return EXIT_FAILURE;
}