Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - TCP/IP Response delay: (4 Items)
   
TCP/IP Response delay  
Dear readers,

I'm have a small TCP server that wait for commands and sends back responses. One of the commands sends back two  
response values in two seperate send calls. When measuring the response delay in the client application (on WIN32) I 
notice the following; the first response is received without any notable delay < 1ms, the second response will have a 
delay of about 200ms. This delay is quit fixed. 

 Some while ago I stumbled into the same behaviour sending telnet requests from a windows application that came back 
(response) into multiple packets (using a sniffer to watch the traffic) the first fraction(ip packet) of the telnet 
response had a low response delay, the second fraction of the telnet response also had a delay of about 200 ms. 

So the main questions is. Is this some kind of TCP/IP stack problem or do I one way or the other misuse the stack.  

All help is appreciated

Thanks Wim
RE: TCP/IP Response delay  
Shot in the dark:

  client_socket = accept(listen_socket, 0, 0));
  // error handling

  int flag=1;
  rc = setsockopt(client_socket, IPPROTO_TCP, TCP_NODELAY, (char*)&flag,
sizeof(int));
  // error handling

Would not bet a fortune but you may have luck.

cf: http://www.unixguide.net/network/socketfaq/2.16.shtml

--
Mate
Re: RE: TCP/IP Response delay  
You should have bet a fortune -:)
 
It's working now wthout the delay 

Thank you very much !

Regards
Wim
Re: TCP/IP Response delay  
Yes, Mate is right,

TCP's Nagle algorithm attempts to buffer small writes which is usually 
best. For interactive applications though, it is better to turn it off.

/P