| 63 | } |
| 64 | |
| 65 | int main(int argc, char* argv[]) |
| 66 | { |
| 67 | try |
| 68 | { |
| 69 | if (argc != 2) |
| 70 | { |
| 71 | std::cerr << "Usage: daytime_client <host>" << std::endl; |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | boost::asio::io_context io_context; |
| 76 | |
| 77 | // Set the name of the file that all logger instances will use. |
| 78 | services::logger logger(io_context, ""); |
| 79 | logger.use_file("log.txt"); |
| 80 | |
| 81 | // Resolve the address corresponding to the given host. |
| 82 | tcp::resolver resolver(io_context); |
| 83 | tcp::resolver::results_type endpoints = |
| 84 | resolver.resolve(argv[1], "daytime"); |
| 85 | |
| 86 | // Start an asynchronous connect. |
| 87 | tcp::socket socket(io_context); |
| 88 | boost::asio::async_connect(socket, endpoints, |
| 89 | std::bind(connect_handler, |
| 90 | boost::asio::placeholders::error, &socket)); |
| 91 | |
| 92 | // Run the io_context until all operations have finished. |
| 93 | io_context.run(); |
| 94 | } |
| 95 | catch (std::exception& e) |
| 96 | { |
| 97 | std::cerr << e.what() << std::endl; |
| 98 | } |
| 99 | |
| 100 | return 0; |
| 101 | } |
nothing calls this directly
no test coverage detected