| 58 | }; |
| 59 | |
| 60 | int main(int argc, char* argv[]) |
| 61 | { |
| 62 | try |
| 63 | { |
| 64 | if (argc != 2) |
| 65 | { |
| 66 | std::cerr << "Usage: async_udp_echo_server <port>\n"; |
| 67 | return 1; |
| 68 | } |
| 69 | |
| 70 | boost::asio::io_context io_context; |
| 71 | auto work = boost::asio::make_work_guard(io_context); |
| 72 | std::thread t([&](){io_context.run();}); |
| 73 | |
| 74 | server s(io_context, std::atoi(argv[1])); |
| 75 | |
| 76 | work.reset(); |
| 77 | t.join(); |
| 78 | } |
| 79 | catch (std::exception& e) |
| 80 | { |
| 81 | std::cerr << "Exception: " << e.what() << "\n"; |
| 82 | } |
| 83 | |
| 84 | return 0; |
| 85 | } |