Wednesday, March 20, 2013

500 millisec (ms) delay in 'ACK' of TCP/IP in Visual Studio (VS) VC++ ???

Current post is on how to overcome 500 millisecond (ms) delay in 'ACK' acknowledge of send command in TCP/IP in Visual Studio (VS) Visual C++ (VC++) Application


Are you getting a constant 500ms delay in Acknowledgement of send command in TCP/IP in Visual Studio (VS) Visual C++ (VC++) Application??

Is your application sending lot of small data packets in large frequency over TCP/IP sockets in Visual Studio (VS) Visual C++ (VC++) Application??

If the answer is YES, copy the following lines of code after the 'bind' function call to improve the performance of the application:

Disable the Nagle Algorithm:

int value = 1;
setsockopt(, IPPROTO_TCP, TCP_NODELAY, (char *)&value, sizeof (value));

Note:-
1. Application should be able to handle short and large number of TCP/IP socket calls
2. Network Traffic will increase as the underlying protocol won't wait for threshold bytes before sending.


Enable the Nagle Algorithm:

int value = 0;
setsockopt(, IPPROTO_TCP, TCP_NODELAY, (char *)&value, sizeof (value));

Complie. Run. Test and enjoy coding.

Appreciate your feedback via comments. Thanks.

No comments:

Post a Comment

Disclaimer:

The above post and all the posts in the blog are derived from facts, information, logical interpretation and logical conclusion of printed and internet materials available to me, perceived and produced by 99 gm brain of mine, which by no means always be accurate, consistent and complete.

All the posts are for personal quick reference only.

If any suggestion, correction, misinterpretation, misconception commented, which will be moderated and deleted if required, to avoid unforeseen issues.

If any trademark / copywrite issue is present, do send in a mail and appropriate tag (logo, name, website link) will be attached to the same.

Additional disclaimer will be attached wherever required in the post.