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

mitch.seybold at gmail.com mitch.seybold at gmail.com
Thu Feb 28 11:38:18 CST 2008


Thanks for the quick reply, Doug.

acetao-1.5.1.0  Windows XP
Will have to run down PROBLEM-REPORT-FORM as our sys admin did not
place it in $ACE_ROOT

I attempted to limit the number of connection in the
Gateway::ConnectionAcceptor::make_svc_handler by not instantiating a
new SvcHandler and returning from the method if svcHandler_ was not
0.  When I returned 0, my process core dumped.  What should be
returned?

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

    if (svcHandler_ != 0)   // already have a svcHandler (peer)
    {
        std::cout << "Gateway::ConnectionAcceptor::make_svc_handler "
            << "client already connected." << std::endl;
        return 0;   // THIS CAUSED CORE DUMP
    }

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


On Feb 28, 9:58 am, schm... at dre.vanderbilt.edu (Douglas C. Schmidt)
wrote:
> 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.schm... at vanderbilt.edu- Hide quoted text -
>
> - Show quoted text -



More information about the Ace-users mailing list