title: Socket programming issue with recv() receiving partial messages
body: <p>I have a socket that is receiving streaming stock tick data. However, I seem to get a lot of truncated messages, or what appears to be truncated messages. Here is how I am receiving data:</p>
  
  <pre><code>if((numbytes = recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) {
      perror("recv()");
      exit(1);
  }
  else {
      buf[numbytes] = '\0';
      // Process data
  }
  </code></pre>
  
  <p>Can <code>recv()</code> receive just a partial message of what was sent?</p>
  
  <p>My feeling is I might need another loop around the <code>recv()</code> call that receives until a complete message is sent. I know that a libcurl implementation I have (not possible to use libcurl here I would think) has an outer loop:</p>
  
  <pre><code>// Read the response (sum total bytes read in tot_bytes)
  for(tot_bytes=0; ; tot_bytes += iolen)
  {  
      wait_on_socket(sockfd, 1, 60000L);
      res = curl_easy_recv(curl, buf + tot_bytes, sizeof_buf - tot_bytes, &amp;iolen);
  
      if(CURLE_OK != res) {
          // printf( "## %d", res );
          break;
      }
  }
  </code></pre>
  
  <p>Do I need an <code>recv()</code> loop similar to the libcurl example (that verifiably works)?</p>