Reconnecting a SSL socket correctly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Reconnecting a SSL socket correctly

Boost - Users mailing list
Hello,

I'm trying to reconnect a SSL socket (using ssl::stream with tcp::socket) that has been closed only remotely. It looks like a shutdown on my client causes "stream truncated" error so I have no idea how can I connect my client socket again.

I was thinking of just creating a new instance but the stream class is not copyable.

Do you have any recommandations?

Regards,

--
David
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Reconnecting a SSL socket correctly

Boost - Users mailing list
On Wed, Oct 18, 2017 at 4:26 AM, David Demelier via Boost-users
<[hidden email]> wrote:
> Do you have any recommandations?

Put the stream inside a boost::optional and call emplace when you want
to construct it or reconnect:

    boost::optional<
       boost::asio::ssl::stream<
           boost::asio::ip::tcp::socket>> stream;

    stream.emplace(ios, ctx);

Thanks
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users