[asio-users] boost::asio::ssl creating a ssl wrapper around an already established tcp socket
Brought to you by:
chris_kohlhoff
From: Daniel M. <im...@im...> - 2006-09-03 02:05:03
|
Hi, I'm working a bit with boost::asio and i'm trying to get a ssl wrapper around an already established tcp socket (which is boost::asio::ip::tcp::socket). Appearently from the documentation and the example on the website, i have to create the ssl wrapper with a template socket boost::asio::ssl::stream<mystreamsockettype>. But then i would have to build a tcp connection on the lowest layer of that stream. Isn't it possible to create a wrapper on an already working tcp socket? Code Example: using boost::asio::ip::tcp; boost::asio::io_service io_service; boost::asio::error error; tcp::resolver resolver(io_service); tcp::resolver::query query("myhost", "myserv"); tcp::resolver::iterator endpoint_iterator, end; tcp::socket socket(io_service); endpoint_iterator = resolver.resolve(query); error = boost::asio::error::host_not_found; while (error && endpoint_iterator != end) { socket.close(); socket.connect(*endpoint_iterator++, boost::asio::assign_error(error)); } if (error) throw error; // do io operations on my tcp socket using boost::asio::ssl; ssl::context ctx(io_service, ssl::context::tlsv1); // create my ssl wrapper here Thanks in advance impulze |