Why the network communication latency Increase when I add a sleep() after socket.send()?
I want to do inter process communication(IPC) use socket interface, the protocol i used is tcp. then I write a demo to test RTT. A clinet record current time and send() data in a loop using stream. A server record current time and recv() data in a loop. I curious about that socket buffer in kernel will be full and affect the result. So, and send() the client will sleep 1ms. Then I test it again, the RTT increase a lot! I don't know why it increase, i thought it should be same or decrease?
A simple demo like below:
client:
`
while(1){
uint64_t send_time = now();
socket.send();
sleep(1);
}
`
server:
`
while(1){
uint64_t receive_time = now();
socket.recv();
}
`