Boost logo

Boost :

Subject: [boost] Connection refused after close then open
From: Doak, Roger (GE Healthcare) (Roger.Doak_at_[hidden])
Date: 2010-09-20 11:25:11


Hi

I'm trying to limit the connections made to the server.
So after creating the acceptor and accepting MAX connections I closed
the acceptor.
If there is a better way please let me know.
Further connections are properly rejected.
However after one of the connections is closed by the client I attempt
to re-open the acceptor
but further connections are still rejected?

Create and open:
m_acceptor(m_ioService, m_endpoint = resolve(m_ioService, host, port),
true)

Async accept:
m_acceptor.async_accept(connection->socket(),
boost::bind(&IpServer::handleAccept, this, aph::error, connection));

Close after max connections:
m_acceptor.close();

Reopen when a connection is available:
m_acceptor.open(m_endpoint.protocol());
m_acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true
));
m_acceptor.bind(m_endpoint);
m_acceptor.listen();
m_acceptor.async_accept(connection->socket(),
boost::bind(&IpServer::handleAccept, this, aph::error, connection));

Thank you for your time.

Roger


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk