[Ace-users] Configure number of connections ACE_Acceptor will accept

mitch.seybold at gmail.com mitch.seybold at gmail.com
Thu Feb 28 10:51:41 CST 2008


Hello -
Let me apologize in advance for my ignorance.  I'm an old socket guy.

I am using ACE_Acceptor and would like to configure the number of
accepts (1..n) the Acceptor will allow.

Basically, if nConnections = 1, the ACE_Acceptor will create one
SvcHandler and any more connection requests should result in
'connection refused' by the requesting peer.  If the connected peer
closes the connection, the next connection request will be accepted.

Using the following, all connection requests are accepted and multiple
SvcHandlers are instantiated.

Currently:

Gateway::ConnectionAcceptor::ConnectionAcceptor(Gateway* gateway)
    : gateway_ (gateway)
    , svcHandler_(0)
{
    std::cout << "Gateway::ConnectionAcceptor::ConnectionAcceptor... "
            << "listening on port " << gatewayData_->listenPort
            << std::endl;

   nConnections_ = gatewayData_->nConnections;  // unused at this
point
}

Gateway::ConnectionAcceptor::~ConnectionAcceptor()
{
    std::cout << "Gateway::ConnectionAcceptor::~ConnectionAcceptor..."
            << std::endl;
    }
    if (svcHandler_)
    {
        svcHandler_->close();
        delete svcHandler_;
        svcHandler_ = 0;
    }
}

int Gateway::ConnectionAcceptor::make_svc_handler(SvcHandler*&
svcHandler)
{
    std::cout << "Gateway::ConnectionAcceptor::make_svc_handler..."
            << "  i.e. connection request" << std::endl;
    }

    svcHandler_ = new SvcHandler(gateway_, gatewayData_);
    svcHandler_->reactor(ACE_Reactor::instance());
    svcHandler = svcHandler_;
    return 0;
}

Any ideas would be appreciated.


More information about the Ace-users mailing list