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 mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
According to that document, you should not enocounter this problem
when using blocking sockets. Probably your socket is not blocking?
To make a socket blocking you should write something like this:
boost::asio::socket_base::non_blocking_io command(true);
socket.io_control(command);
thanks for your reply.
I guess you mean setting non_blocking_io to false.
Tried to enter those lines, but still have no change:
boost::asio::socket_base::non_blocking_io command(false);
socket.io_control(command);
Tobias
I inserted.
int on=1;
setsockopt(socket.native(), IPPROTO_TCP, TCP_NODELAY, (char *)&on,
sizeof(on) );
right after I open the connection. Still no change :(
Tobias
2009/3/25 张亚霏 <kimi67...@qq.com>: