@@ -7,9 +7,7 @@ using namespace cli;
77
88int main (void )
99{
10- try
11- {
12- boost::asio::io_context io_context;
10+ boost::asio::io_service io_service;
1311 unsigned int port;
1412 bool set_port = false ;
1513
@@ -20,14 +18,21 @@ int main(void)
2018 {
2119 if (set_port)
2220 {
23- server s (io_context, port);
24- std::cout << " \t SERVER STARTED ON " << port << std::endl;
25- if (io_context.stopped ())
26- io_context.restart ();
27- io_context.run ();
21+ try
22+ {
23+ server s (io_service, port);
24+ std::cout << " \t SERVER STARTED ON " << port << std::endl;
25+ if (io_service.stopped ())
26+ io_service.restart ();
27+ io_service.run ();
28+ }
29+ catch (const std::exception& e)
30+ {
31+ std::cerr << " SERVER> Exception: " << e.what () << " \n " ;
32+ }
2833 }
2934 else {
30- out << " You must set port for server. Use: \" setPort <value >\" " << " \n " ;
35+ out << " You must set port for server. Use: \" setPort <int >\" " << " \n " ;
3136 }
3237 },
3338 " Start server" );
@@ -54,9 +59,16 @@ int main(void)
5459 [&](std::ostream& out)
5560 {
5661 if (set_port){
57- if (!io_context.stopped ())
58- io_context.stop ();
59- out << " \t STOPED ON PORT " << port << std::endl;
62+ try
63+ {
64+ if (!io_service.stopped ())
65+ io_service.stop ();
66+ out << " \t STOPED ON PORT " << port << std::endl;
67+ }
68+ catch (const std::exception& e)
69+ {
70+ std::cerr << " SERVER> Exception: " << e.what () << " \n " ;
71+ }
6072 }
6173 else {
6274 out << " You don't specify the port or don't start the server." << " \n " ;
@@ -65,21 +77,16 @@ int main(void)
6577 " Stop server" );
6678
6779 Cli cli (std::move (rootMenu));
68- cli.ExitAction ([&io_context ](auto & out)
80+ cli.ExitAction ([&io_service ](auto & out)
6981 {
70- if (!io_context .stopped ())
71- io_context .stop ();
82+ if (!io_service .stopped ())
83+ io_service .stop ();
7284
7385 out << " \t EXIT. Goodbye!\n " ;
7486 });
7587
7688 CliFileSession input (cli);
7789 input.Start ();
78- }
79- catch (std::exception& e)
80- {
81- std::cerr << " SERVER> Exception: " << e.what () << " \n " ;
82- }
8390
8491 return 0 ;
8592}
0 commit comments