| 229 | //------------------------------------------------------------------------------ |
| 230 | |
| 231 | int main(int argc, char** argv) |
| 232 | { |
| 233 | // Check command line arguments. |
| 234 | if(argc != 4) |
| 235 | { |
| 236 | std::cerr << |
| 237 | "Usage: websocket-client-async-ssl <host> <port> <text>\n" << |
| 238 | "Example:\n" << |
| 239 | " websocket-client-async-ssl echo.websocket.org 443 \"Hello, world!\"\n"; |
| 240 | return EXIT_FAILURE; |
| 241 | } |
| 242 | auto const host = argv[1]; |
| 243 | auto const port = argv[2]; |
| 244 | auto const text = argv[3]; |
| 245 | |
| 246 | // The io_context is required for all I/O |
| 247 | net::io_context ioc; |
| 248 | |
| 249 | // The SSL context is required, and holds certificates |
| 250 | ssl::context ctx{ssl::context::tlsv12_client}; |
| 251 | |
| 252 | // Verify the remote server's certificate |
| 253 | ctx.set_verify_mode(ssl::verify_peer); |
| 254 | |
| 255 | // This holds the root certificate used for verification |
| 256 | load_root_certificates(ctx); |
| 257 | |
| 258 | // Launch the asynchronous operation |
| 259 | std::make_shared<session>(ioc, ctx)->run(host, port, text); |
| 260 | |
| 261 | // Run the I/O service. The call will return when |
| 262 | // the socket is closed. |
| 263 | ioc.run(); |
| 264 | |
| 265 | return EXIT_SUCCESS; |
| 266 | } |
nothing calls this directly
no test coverage detected