|
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