[ASIO] Create SSL stream from native socket?

Hi, I would like to create an ssl stream for an already accepted native socket, just like is possible with basic_stream_socket< tcp >. How should this be done? Currently there is only one ssl::stream constructor which takes one parameter that is passed to the basic_stream_socket: template <typename Arg, typename Context_Service> explicit stream(Arg& arg, basic_context<Context_Service>& context) : next_layer_(arg), service_(boost::asio::use_service<Service>(next_layer_.get_io_service())), impl_(service_.null()) { service_.create(impl_, next_layer_, context); } To be able to create an ssl stream from an existing socket we would need a constructor which passes three parameters to the basic_stream_socket like this: template <typename Arg1, typename Arg2, typename Arg3, typename Context_Service> explicit stream(Arg1& arg1, Arg2& arg2, Arg3& arg3, basic_context<Context_Service>& context) : next_layer_(arg1, arg2, arg3), service_(boost::asio::use_service<Service>(next_layer_.get_io_service())), impl_(service_.null()) { service_.create(impl_, next_layer_, context); } Would it be a problem to add constructors that passes two and three parameters to the basic_stream_socket or can this be done in another way? Kind regards, M. Fransen _________________________________________________________________ New Windows 7: Simplify what you do everyday. Find the right PC for you. http://windows.microsoft.com/shop

On 23.3.2010 13:55, Marcel Fransen wrote:
I would like to create an ssl stream for an already accepted native socket, just like is possible with basic_stream_socket<tcp>. How should this be done?
If you already have a tcp::socket you can specify your ssl stream to use a reference to tcp socket as its first template parameter: ssl::stream<ip::tcp::socket &> ssl_stream( existing_socket, ... ); Of course, you need to insure that 'ssl_stream' does not outlive 'existing_socket'. HTH
participants (2)
-
Juraj Ivančić
-
Marcel Fransen