Hello, I am using cxxtools as a http server in a embedded system and I am
facing some latency in my requests. The server uses cxxtools and in the
client side I use CURL. The normal message delivering time here (local
network) is about 1~2 ms, but sometimes I have exactly 200ms, which I guess
is caused by ack delays. In the client side I have setup TCP_NODELAY (curl
has an option for it) which reducs the problem with the Nagling algorithm,
but I could not find a way to do this in the server side.

THis problem is hapenning due the small size of the message the server
transmits to the client: something which varies from 20 to 80 bytes. With
the http related things, it's about 140 bytes. But I need to deliver it
with no delay (200ms is too much for this system). I'm currently reusing
the connection, so TCP handshaking is not the problem.

My first try was changing cxxtools source code, adding  the code [1] on
tcpserverimpl.cpp, method listen, just after "setsockopt SO_REUSEADDR" if
code. By debugging my app, I checked the code is being executed, so
TCP_NODELAY is being applied, but I have the same behavior as before, which
means it didn't work.

Anyway, I would not like to keep this change only in my local repo, rather
a better implementation in cxxtools (which could be enabled/disabled in
runtime) as most people don't want this behavior.

To sum up, my problems are: how to solve my delay problems and how to put
it in cxxtools in a portable way.

Thank you in advance.

[1]
            log_debug("setsockopt TCP_NODELAY");
            if (::setsockopt(fd, SOL_TCP, TCP_NODELAY, &on, sizeof(on)) < 0)
            {
                log_debug("could not set socket option TCP_NODELAY " << fd
<< ": " << getErrnoString());
                ::close(fd);
                continue;
            }

-- 
Sent from my mind
------------------------------------------------------------------------------
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to