Boost logo

Boost Users :

Subject: [Boost-users] pass asio socket to another class
From: cap (cap.nick_at_[hidden])
Date: 2014-12-10 08:55:00

I have two classes SslHandshake and SslRequest with according to names

After client and server handshakes are done in the SslHandshake, I pass both
sockets to SslRequest and start transferring data from server to client.

1. If I is not waiting for finishing of transferring, instance of
SslHandshake will be destroyed automatically (in the ~SslHandshake I will
destroy both socket objects and transferring in the SslRequest will be
2. If I start transferring with waiting, after a few iterations
SslRequest::ReadSocketOut will be called successfully, but the
readSocketHandle will not be called (so, will be called but with timeout

So, I need to handshake in one class and transfer data into another class.

How to prevent destroying instance of SslHandshake until data transferring
will be done into SslRequest or how to fix socket reading without callback
calling after a few iterations?

void SslHandshake::HandshakeInHandle(const bSystem::error_code &error)
            LOG_MSG_DEBUG_KEYWORD(KEYWORD_INCOMING, << "Handshake done");

            // --- Transfer with waiting of mutex
            //IoServicePtr servicePointer((IoService
            //SslRequest::SharedPtr sslRequest(new SslRequest(m_SocketIn,

            SslRequest::SocketPtr socketIn(m_SocketIn);
            SslRequest::SocketPtr socketOut(m_SocketOut);

            // --- Transfer with waiting of thread
            //IoServicePtr servicePointer((IoService
            //servicePointer->SessionIndex = IndexThis;
            //SslRequest::SharedPtr request =
SslRequest::CreateInstance(m_SocketIn, m_SocketOut);

            // --- Transfer with waiting of IO_SERVICE_THREAD_VOID
            IoServicePtr servicePointer((IoService
            servicePointer->SessionIndex = IndexThis;
            SslRequest::SharedPtr request =
SslRequest::CreateInstance(/*m_SocketIn, m_SocketOut*/socketIn, socketOut

void SslRequest::ReadSocketOut(TransferringBuffer &buffer,
SimpleSocketCallback readSocketHandle)

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at