Boost logo

Boost Users :

Subject: [Boost-users] Boost::asio, set tcp_nodelay, bad file descriptor?
From: Alex Black (alex_at_[hidden])
Date: 2009-08-05 14:22:08


I'm experimenting with turning off the Nagle algorithm to possibly
improve the performance of my socket server, I'm processing lots of
small requests and I'd like as little latency as possible.

Here is a code snippet:

void CBaseWebServer::StartAccept()
{
        try
        {
                shared_ptr<tcp::socket> pSocket(new
tcp::socket(m_IoService));

                boost::asio::ip::tcp::no_delay option(true);
                pSocket->set_option(option);

                m_pAcceptor->async_accept(*pSocket,
bind(&CBaseWebServer::HandleAccept, this, pSocket,
boost::asio::placeholders::error));
        }
        catch ( ... )
        {
                cout << "Unexpected exception caught in " <<
BOOST_CURRENT_FUNCTION << endl <<
boost::current_exception_diagnostic_information();
        }
}

I'm getting an exception on the set_option line:

Unexpected exception caught in void CBaseWebServer::StartAccept()
Throw in function (unknown)
Dynamic exception type:
N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_6syst
em12system_errorEEEEE
std::exception::what: Bad file descriptor

What am I doing wrong here? Thanks!

- Alex


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