Note that there are some explanatory texts on larger screens.

plurals
  1. POReasons for a slow recv call
    text
    copied!<p>I'm writing two applications (in C), which make several calls to send and receive (e.g. I'm implementing a remote file copy).</p> <p>I always send a 64 Byte Header which contains the length of the following message body and some other information. </p> <p>When testing my application on some files I recognized that some recv calls take a pretty long time to complete (about 40 <strong>ms</strong>). Using strace I found out that it happens first when sending a message body of 377 Bytes (which in this case it the whole content of my file to copy). </p> <p>The server application starts sending the message body which takes about 48 <strong>us</strong>. Now the client application consumes about 38 <strong>ms</strong> to receive these bytes. </p> <p>From that time on every receive calls consumes that much time, since they are each blocking in a receive and waiting for the reply.</p> <p><strong>server's strace</strong></p> <p>[pid 27158] 1292236124.465827 send(6, "\0\0\1\271\0\0\0\0\0\0\0\0core.fwrite\0\0\0\0\0\0\0\0\0"..., 64, 0) = 64 &lt;0.000031></p> <p>[pid 27158] 1292236124.466074 send(6, "\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0"..., 377, 0) = 377 &lt;0.000048></p> <p><strong>client's strace</strong></p> <p>[pid 27159] 1292236124.466364 recv(4, "\0\0\1\271\0\0\0\0\0\0\0\0core.fwrite\0\0\0\0\0\0\0\0\0"..., 64, 0) = 64 &lt;0.000027></p> <p>[pid 27159] 1292236124.466597 recv(4, "\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0"..., 377, 0) = 377 &lt;0.037456></p> <p>This problem really gives me a hard time since I do not understand why the receive call on the client takes so much time.</p> <p>Any hints would be highly appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload