classes/CSocket.cpp
void CSocket::cleanup()
    {
        try
        {
            if (m_isListenThreadRunning && m_socketListenThread)
            {
                m_isListenThreadRunning = false;
                try
                {
                    boost::asio::ip::tcp::socket socket{m_ioService};
                    boost::asio::ip::tcp::resolver::query query(m_hostAddress, m_hostPort);
                    boost::asio::connect(socket, m_ioQueryResolver.resolve(query));
                    socket.close();
                }
                catch (std::exception &e)
                {
                    throw std::runtime_error("Could not wake listener thread with fake connect.");
                }
                m_socketListenThread->join();
            }
            close();
        }
        catch (const std::exception &e)
        {
            throw Exception(e.what());
        }
    }
// ==============
// PUBLIC METHODS
// ==============
//
// Cleanup after socket connection. This includes stopping any unused listener
// thread and closing the socket if still open. Note: if the thread is still waiting
// for a connect it is woken up with a fake connect.
//
PUBLIC METHODS
Cleanup after socket connection. This includes stopping any unused listener
thread and closing the socket if still open. Note: if the thread is still waiting
for a connect it is woken up with a fake connect.
PUBLIC METHODS Cleanup after socket connection . This includes stopping any unused listener thread and closing the socket if still open . Note : if the thread is still waiting for a connect it is woken up with a fake connect .
void CSocket::cleanup()
    {
        try
        {
            if (m_isListenThreadRunning && m_socketListenThread)
            {
                m_isListenThreadRunning = false;
                try
                {
                    boost::asio::ip::tcp::socket socket{m_ioService};
                    boost::asio::ip::tcp::resolver::query query(m_hostAddress, m_hostPort);
                    boost::asio::connect(socket, m_ioQueryResolver.resolve(query));
                    socket.close();
                }
                catch (std::exception &e)
                {
                    throw std::runtime_error("Could not wake listener thread with fake connect.");
                }
                m_socketListenThread->join();
            }
            close();
        }
        catch (const std::exception &e)
        {
            throw Exception(e.what());
        }
    }
void CSocket :: cleanup ( ) { try { if ( m_isListenThreadRunning && m_socketListenThread ) { m_isListenThreadRunning = false ; try { boost :: asio :: ip :: tcp :: socket socket { m_ioService } ; boost :: asio :: ip :: tcp :: resolver :: query query ( m_hostAddress , m_hostPort ) ; boost :: asio :: connect ( socket , m_ioQueryResolver . resolve ( query ) ) ; socket . close ( ) ; } catch ( std :: exception & e ) { throw std :: runtime_error ( " " ) ; } m_socketListenThread -> join ( ) ; } close ( ) ; } catch ( const std :: exception & e ) { throw Exception ( e . what ( ) ) ; } }
PUBLIC METHODS
Cleanup after socket connection.
PUBLIC METHODS Cleanup after socket connection .