recv() with MSG_PEEK shows full message but returns 'would block' normally <p>I have a non-blocking winsock socket that is <code>recv</code>'ing data in a loop.</p> <p>I noticed that when connecting with, say, putty and a raw socket, sending messages works just fine. However, when interfacing with this particular client, the packets seem to not be triggering a successful, non-<code>MSG_PEEK</code> call to <code>recv</code>. I recall having a similar issue a few years back and it ended up having to end the packets in <code>\r</code> or something coming from the <em>client</em>, which isn't possible in this case since I cannot modify the client.</p> <p>Wireshark shows the packets coming through just fine; my server program, however, isn't working quite right.</p> <p>How would I fix this?</p> <p><strong>EDIT:</strong> Turning the buffer size down to, say, 8 resulted in a few <em>successful</em> calls to recv without MSG_PEEK.</p> <p>Recv call:</p> <pre><code>iLen = recv(group-&gt;clpClients[cell]-&gt;_sock, // I normally call without MSG_PEEK group-&gt;clpClients[cell]-&gt;_cBuff, CAPS_CLIENT_BUFFER_SIZE, MSG_PEEK); if(iLen != SOCKET_ERROR) { ... </code></pre> <p>Socket is <code>AF_INET</code>, <code>SOCK_STREAM</code> and <code>IPPROTO_TCP</code>.</p>