Boost logo

Boost Users :

Subject: [Boost-users] [asio] Disable nagle algorithm on Windows XP
From: Tobias Jähnel (tjaehnel_at_[hidden])
Date: 2009-03-25 08:28:33


I'm developing a TCP-Client using boost::asio and discovered that ACKs
to responses from the server are sent with some delay (~200ms) and I
get the data not before this ACK has been sent.

When I disable nagle in registry as described by Microsoft it works fine.

To avoid those registry hacks I want to find another way to get rid of
this latency.
I'm already using blocking sockets as suggest in above document.

I also tried to set the no_delay option but this has no effect at all.
 boost::asio::ip::tcp::no_delay option(true);

== Code Snippets ==
I use the boost asio library as follows:

 // open connection (from synchronous TCP daytime client example)
 boost::asio::io_service io_service;
 tcp::resolver resolver(io_service);
 tcp::resolver::query query(ipaddress, port);
 tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
 tcp::resolver::iterator end;
 boost::system::error_code error = boost::asio::error::host_not_found;
 while (error && endpoint_iterator != end)
     socket.connect(*endpoint_iterator++, error);

 // send some data
 boost::asio::write(socket, boost::asio::buffer(package, size));

 // reception is done inside a thread
    // receive data
    size_t length = socket.read_some(boost::asio::buffer(resp), error);
    if (error == boost::asio::error::eof)
    { // Connection closed cleanly by peer.
        // ... do sth. }
    else if (error)
    { // Some error has happened
       // ... do sth.
    // ... process received data and notify main thread to send the
next piece of data

Thank you for all suggestions.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at