[Boost-users] Reconnecting a SSL socket correctly

549 views
Skip to first unread message

David Demelier via Boost-users

unread,
Oct 18, 2017, 10:25:59 AM10/18/17
to boost...@lists.boost.org, David Demelier
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
Boost...@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users

Vinnie Falco via Boost-users

unread,
Oct 18, 2017, 12:23:40 PM10/18/17
to boost...@lists.boost.org, Vinnie Falco
On Wed, Oct 18, 2017 at 4:26 AM, David Demelier via Boost-users
<boost...@lists.boost.org> 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
Reply all
Reply to author
Forward
0 new messages