| 189 | //---------------------------------------------------------------------- |
| 190 | |
| 191 | int main(int argc, char* argv[]) |
| 192 | { |
| 193 | try |
| 194 | { |
| 195 | if (argc < 2) |
| 196 | { |
| 197 | std::cerr << "Usage: chat_server <port> [<port> ...]\n"; |
| 198 | return 1; |
| 199 | } |
| 200 | |
| 201 | boost::asio::io_context io_context(1); |
| 202 | |
| 203 | for (int i = 1; i < argc; ++i) |
| 204 | { |
| 205 | unsigned short port = std::atoi(argv[i]); |
| 206 | co_spawn(io_context, |
| 207 | listener(tcp::acceptor(io_context, {tcp::v4(), port})), |
| 208 | detached); |
| 209 | } |
| 210 | |
| 211 | boost::asio::signal_set signals(io_context, SIGINT, SIGTERM); |
| 212 | signals.async_wait([&](auto, auto){ io_context.stop(); }); |
| 213 | |
| 214 | io_context.run(); |
| 215 | } |
| 216 | catch (std::exception& e) |
| 217 | { |
| 218 | std::cerr << "Exception: " << e.what() << "\n"; |
| 219 | } |
| 220 | |
| 221 | return 0; |
| 222 | } |
nothing calls this directly
no test coverage detected