|
Boost Users : |
Subject: Re: [Boost-users] Connection refused after close then open.
From: Doak, Roger (GE Healthcare) (Roger.Doak_at_[hidden])
Date: 2010-09-16 12:17:01
Hi
Maybe I ask the question the wrong way.
What is the proper way for a server to limit the connections.
Even if I don't start another async_accept clients can still connect but
not communicate.
That's why I called close. Is there a better way?
Thanks
Roger
> I'm trying to limit the connections made to the server.
> So after creating the acceptor and accepting MAX connections I closed
> the acceptor.
> 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(tr
> ue));
> m_acceptor.bind(m_endpoint);
> m_acceptor.listen();
>
> Thanks for your time.
> Roger
>
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