-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserwer.cpp
More file actions
68 lines (55 loc) · 1.87 KB
/
serwer.cpp
File metadata and controls
68 lines (55 loc) · 1.87 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <boost/program_options.hpp>
#include "server_attributes.h"
#include "server.h"
namespace po = boost::program_options;
bool parse_command_line(int argc, char** argv)
{
po::options_description description("Server usage");
description.add_options()
("help,h", "Display this help message")
("port,p", po::value<unsigned>(&server_attributes::port), "Port number")
("fifosize,F", po::value<unsigned>(&server_attributes::fifo_size), "Fifo size")
("fifolowwatermark,L", po::value<unsigned>(&server_attributes::fifo_low_watermark), "Fifo low watermark")
("fifohighwatermark,H", po::value<unsigned>(&server_attributes::fifo_high_watermark), "Fifo high watermark")
("buflen,X", po::value<unsigned>(&server_attributes::buf_len), "Buffer length")
("txinterval,i", po::value<unsigned>(&server_attributes::tx_interval), "Tx interval");
po::variables_map vm;
try
{
po::store(po::command_line_parser(argc, argv).options(description).run(), vm);
po::notify(vm);
}
catch (std::exception& ex)
{
if (!vm.count("help"))
std::cerr << description;
return 1;
}
if (vm.count("help"))
{
std::cerr << description;
return 1;
}
if (!vm.count("fifohighwatermark"))
server_attributes::fifo_high_watermark = server_attributes::fifo_size;
return 0;
}
int main(int argc, char** argv)
{
std::ios_base::sync_with_stdio(false); //Przyspieszenie cerr.
asio::io_service io_service;
if (parse_command_line(argc, argv))
return 0;
server serwer(io_service);
try
{
serwer.setup();
io_service.run();
}
catch (std::exception& e)
{
std::cerr << "[Error] '" << e.what() << "'" << std::endl;
}
std::cerr << "[FINISHED]" << std::endl;
}