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


Hi,

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.
(See: http://support.microsoft.com/kb/823764)

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);
 socket.set_option(option);

== 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.close();
     socket.connect(*endpoint_iterator++, error);
 }

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

 // reception is done inside a thread
 while(true)
 {
    // 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.

Tobias


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