title: recv returns old data
body: <p>This loop is supposed to take data from a socket line by line and put it in a buffer. For some reason, when there is no new data to return, recv returns the last couple lines it got. I was able to stop the bug by commenting out the first recv, but then I cant tell how long the next line will be. I know it's not a </p>
  
  <pre><code>while(this-&gt;connected){
      memset(buf, '\0', sizeof(buf));
      recv(this-&gt;sock, buf, sizeof(buf), MSG_PEEK);           //get length of next message
      ptr = strstr(buf, "\r\n");
      if (ptr == NULL) continue;
      err = recv(this-&gt;sock, buf, (ptr-buf), NULL);    //get next message
  
      printf("--%db\n%s\n", err, buf);
  
      tok[0] = strtok(buf, " ");
      for(i=1;tok[i-1]!=NULL;i++) tok[i] = strtok(NULL, " ");
  
  //do more stuff
  }
  </code></pre>