Socket ping-pong performance
- by Kamil_H
I have written two simple programs (tried it in C++ and C#).
This is pseudo code:
-------- Client ---------------
for(int i = 0; i < 200.000; i++)
{
socket_send("ping")
socket_receive(buff)
}
--------- Server -------------
while(1)
{
socket_receive(buff)
socket_send("pong")
}
I tried it on Windows.
Execution time of client is about 45 seconds. Can somebody explain me why this takes so long?
I understand that if there were real network connection between client and server the time of one 'ping-pong' would be:
generate_ping + send_via_network + generate_pong + send_via_network
but here everything is done in 'local' mode.
Is there any way to make this inter process ping-pong faster using network sockets (I'm not asking about shared memory for example :) )