Your problem is probably due to bad interaction between tcp delayed ack and
nagle's algorithm. Nagle's algorithm won't send another packet until its
last in flight packet is acked, if the current pkt is too small; on the
other hand , at the other end, tcp will only send every other ack due to the
delayed ack policy
If all your packets are small it's almost guaranteed that you ll ran into
the situation where nagle's algorithm's end is waiting for its previous ack,
and the delayed ack end is not sending the ack but waiting for nagle's end
to send the next packet. The dead lock will result in a timeout which is
around 30ms in Linux, but could be up to 200ms in windows.
This is a common problem for apps with frequent small packets. The solution
is to disable either nagle's algorithm or delayed ack, both could be
achieved by set socket opt.