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

Douglas C. Schmidt schmidt at dre.vanderbilt.edu
Thu Feb 28 10:58:23 CST 2008


Hi Mitch,

To ensure that we have proper version/platform/compiler information,
please make sure you fill out the appropriate problem report form
(PRF), which is in

$ACE_ROOT/PROBLEM-REPORT-FORM
$TAO_ROOT/PROBLEM-REPORT-FORM

or in

$ACE_ROOT/BUG-REPORT-FORM
$TAO_ROOT/BUG-REPORT-FORM

in older versions of ACE+TAO.  Make sure to include this information
when asking any questions about ACE+TAO since otherwise we have to
"guess" what version/platform/compiler/options you've using, which is
very error-prone and slows down our responsiveness.  If you don't use
the PRF, therefore, it is less likely that someone from the core
ACE+TAO developer team will be able to answer your question.
Naturally, we encourage and appreciate other members of the ACE+TAO
user community who can respond to questions that they have the answers
to.

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

No problemo - that's where I started too!

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

Ok.

>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.

There are various ways you could do this.  One easy one would be to
subclass from ACE_Acceptor and override the make_svc_handler() method
to keep track of the number of active connections and only create a
new SvcHandler if the number of active connections is below
nConnections_.  Naturally, you'd need to define some sort of callback
method in your ACE_Aceptor subclass that your SvcHandler will call
when a connection is closed so that the nConnection_ count is
maintained properly.

Take care,

     Doug

>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.


-- 
Dr. Douglas C. Schmidt                       Professor and Associate Chair
Electrical Engineering and Computer Science  TEL: (615) 343-8197
Vanderbilt University                        WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203                          NET: d.schmidt at vanderbilt.edu



More information about the Ace-users mailing list