| 195 | //------------------------------------------------------------------------------ |
| 196 | |
| 197 | int main(int argc, char** argv) |
| 198 | { |
| 199 | // Check command line arguments. |
| 200 | if(argc != 4) |
| 201 | { |
| 202 | std::cerr << |
| 203 | "Usage: websocket-client-async <host> <port> <text>\n" << |
| 204 | "Example:\n" << |
| 205 | " websocket-client-async echo.websocket.org 80 \"Hello, world!\"\n"; |
| 206 | return EXIT_FAILURE; |
| 207 | } |
| 208 | auto const host = argv[1]; |
| 209 | auto const port = argv[2]; |
| 210 | auto const text = argv[3]; |
| 211 | |
| 212 | // The io_context is required for all I/O |
| 213 | net::io_context ioc; |
| 214 | |
| 215 | // Launch the asynchronous operation |
| 216 | std::make_shared<session>(ioc)->run(host, port, text); |
| 217 | |
| 218 | // Run the I/O service. The call will return when |
| 219 | // the socket is closed. |
| 220 | ioc.run(); |
| 221 | |
| 222 | return EXIT_SUCCESS; |
| 223 | } |