
I have two classes SslHandshake and SslRequest with according to names functionality. 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 aborted). 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 error). 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) { TRY { CHECK_BOOST_ERROR { LOG_MSG_DEBUG_KEYWORD(KEYWORD_INCOMING, << "Handshake done"); // --- Transfer with waiting of mutex //IoServicePtr servicePointer((IoService *)&m_SocketIn->get_io_service()); //boost::thread serviceThread(boost::bind(&IoService::IO_SERVICE_THREAD_VOID, servicePointer)); //SslRequest::SharedPtr sslRequest(new SslRequest(m_SocketIn, m_SocketOut)); //sslRequest->Transfer(); SslRequest::SocketPtr socketIn(m_SocketIn); SslRequest::SocketPtr socketOut(m_SocketOut); // --- Transfer with waiting of thread //IoServicePtr servicePointer((IoService *)&m_SocketIn->get_io_service()); //servicePointer->SessionIndex = IndexThis; //boost::thread serviceThread(boost::bind(&IoService::IO_SERVICE_THREAD_VOID, servicePointer)); //SslRequest::SharedPtr request = SslRequest::CreateInstance(m_SocketIn, m_SocketOut); //request->Transfer(); //serviceThread.join(); // --- Transfer with waiting of IO_SERVICE_THREAD_VOID IoServicePtr servicePointer((IoService *)&m_SocketIn->get_io_service()); servicePointer->SessionIndex = IndexThis; SslRequest::SharedPtr request = SslRequest::CreateInstance(/*m_SocketIn, m_SocketOut*/socketIn, socketOut INDEX_THIS_PASS); request->Transfer(); servicePointer->IO_SERVICE_THREAD_VOID(); } } CATCH_LOG_STD CATCH_LOG_ANY } void SslRequest::ReadSocketOut(TransferringBuffer &buffer, SimpleSocketCallback readSocketHandle) { bAsIO::async_read( *m_SocketOut, bAsIO::buffer(buffer), boost::bind( readSocketHandle, SHARED_FROM_THIS, baPlaceholders::error, baPlaceholders::bytes_transferred)); } -- View this message in context: http://boost.2283326.n4.nabble.com/pass-asio-socket-to-another-class-tp46700... Sent from the Boost - Users mailing list archive at Nabble.com.