| 402 | //---------------------------------------------------------------------- |
| 403 | |
| 404 | int main(int argc, char* argv[]) |
| 405 | { |
| 406 | try |
| 407 | { |
| 408 | using namespace std; // For atoi. |
| 409 | |
| 410 | if (argc != 4) |
| 411 | { |
| 412 | std::cerr << "Usage: server <listen_port> <bcast_address> <bcast_port>\n"; |
| 413 | return 1; |
| 414 | } |
| 415 | |
| 416 | boost::asio::io_context io_context; |
| 417 | |
| 418 | tcp::endpoint listen_endpoint(tcp::v4(), atoi(argv[1])); |
| 419 | |
| 420 | udp::endpoint broadcast_endpoint( |
| 421 | boost::asio::ip::make_address(argv[2]), atoi(argv[3])); |
| 422 | |
| 423 | server s(io_context, listen_endpoint, broadcast_endpoint); |
| 424 | |
| 425 | io_context.run(); |
| 426 | } |
| 427 | catch (std::exception& e) |
| 428 | { |
| 429 | std::cerr << "Exception: " << e.what() << "\n"; |
| 430 | } |
| 431 | |
| 432 | return 0; |
| 433 | } |