<pre>tcp::resolver resolver{ioc}; _pws = new websocket::stream<tcp::socket>(ioc); //websocket::stream<tcp::socket> ws{ioc}; // Look up the domain name // my server is http://localhost/webstream/wsocket _host = "localhost"; _port = 80; auto const results = resolver.resolve(_host, std::to_string(_port)); if(results.size() == 0) { std::cout<<"failed to connect to websocket server"<<std::endl; delete _pws; _pws = nullptr; return; } // Make the connection on the IP address we get from a lookup net::connect(_pws->next_layer(), results.begin(), results.end()); // Set a decorator to change the User-Agent of the handshake _pws->set_option(websocket::stream_base::decorator( [](websocket::request_type& req) { req.set(http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"); })); _pws->handshake(host, "/");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)