Boost logo

Boost :

Subject: [boost] [ASIO] Create SSL stream from native socket?
From: Marcel Fransen (mhgfransen_at_[hidden])
Date: 2010-03-23 08:55:46


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk