Boost logo

Boost Users :

Subject: Re: [Boost-users] async accept asio thread error
From: Igor R (boost.lists_at_[hidden])
Date: 2011-04-05 14:32:19


> The server runs an async accept on a thread with basically the following
> code:
>   boost::asio::ip::tcp::endpoint endpoint =
> boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), iPort);
>   acceptor.open(endpoint.protocol());
>   acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
>   acceptor.bind(endpoint);
>   acceptor.listen();
>   TcpSessionPtr connection(new TcpSession(io_service));
>   acceptor.async_accept(connection->getSocket(),
> boost::bind(&BoostTcpSocket::handleAccept, this, connection,
> boost::asio::placeholders::error));

Do you mean that the above code runs not in io_service::run() thread?
When does this thread exit, just after it executes the above code?

> So, it sounds reasonable that if the application ends an async accept
> operation may be pending. Now, how could I cancel a pending operation? Is
> there another way to solve the problem?

You can close() your acceptor, but its destructor closes it anyway.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net