Boost ASIO Headache

Posted by bobber205 on Stack Overflow See other posts from Stack Overflow or by bobber205
Published on 2010-06-09T04:03:40Z Indexed on 2010/06/09 4:12 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
|

Man... thought using ASIO in Boost was going to be easy and intuitive. :P

I am starting to get it finally but I am having some trouble. Here's a snippet. I am having several compiler errors on the async_accept line. What am I doing wrong? :P

I've based my code off of this page: http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/tutorial/tutdaytime3/src.html

bool TestSocket::StartListening(int port)
{
    bool didStart = false;

    if (!this->listening)
    {
        //try to listen
        acceptor = new tcp::acceptor(this->myService, tcp::endpoint(tcp::v4(), port));
        didStart = true; //probably change?
        tcp::socket* tempNewSocket = new tcp::socket(this->myService);
        acceptor->async_accept(tempNewSocket, boost::bind(&AlexSocket::NewConnection, this, tempNewSocket, boost::asio::placeholders::error) );
    }
    else //already started!
        return false;

    this->listening = didStart;
    return didStart;
}

void TestSocket::NewConnection(tcp::socket* s, const boost::system::error_code& error)
{

}

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost