Try to search your question here, if you can't find : Ask Any Question Now ?

Standalone asio async_connect not firing off bound handler

HomeCategory: stackoverflowStandalone asio async_connect not firing off bound handler
Avatarsourav asked 4 months ago

I have followed the documentation and examples provided by the boost asio implementation but not having any luck after connecting my client to the server. Regardless of success or failure, the handler is never called. I have verified that the server is receiving and accepting the connection from the client but nothing happens on the clients end to indicate success.

void ssl_writer::main_thread() {
    using namespace std::placeholders;
    using namespace asio::ip;

    tcp::resolver resolver(io_context);
    tcp::resolver::query query("192.168.170.115", "8591");
    tcp::resolver::iterator endpointer_iterator = resolver.resolve(query);

    io_context.run();

    std::cout << "connecting...";
    asio::async_connect(socket.lowest_layer(), endpointer_iterator, std::bind(&ssl_writer::handle_connect, this, _1));
}

//...

void ssl_writer::handle_connect(const std::error_code& error) {
    if (!error) {
        std::cout << "connected!";
    }
    else {
        std::cout << "failed!";
    }
}
1 Answers
Best Answer
AvatarMikhail answered 4 months ago
Your Answer

5 + 17 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com