-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_main.cpp
More file actions
43 lines (38 loc) · 980 Bytes
/
server_main.cpp
File metadata and controls
43 lines (38 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "ElfStreamServer.h"
#include "common.h"
#include "args/args.hxx"
#include <iostream>
int main(const int argc, const char* argv[])
{
args::ArgumentParser argparser("Elf Stream Server", "");
args::HelpFlag help(argparser, "help", "Display this help menu", {"help"});
args::ValueFlag<int> port_arg (argparser, "port", "Port", {'p', "port"});
try
{
argparser.ParseCLI(argc, argv);
}
catch(const args::Help&)
{
std::cout<<argparser;
return EXIT_SUCCESS;
}
// Some args related error
catch (const args::ParseError& e)
{
std::cerr << e.what() << std::endl;
std::cerr << argparser;
return EXIT_FAILURE;
}
// Some args validation related error
catch (const args::ValidationError& e)
{
std::cerr << e.what() << std::endl;
std::cerr << argparser;
return EXIT_FAILURE;
}
const int port =
port_arg?args::get(port_arg):ELFSTREAM_PORT;
ElfStreamServer server;
std::cout<<"Launching server on port "<<port<<std::endl;
server.listen(port);
}