title: Winsock recv() does not block
body: <p>I have just compiled this code:
  <a href="http://www.win32developer.com/tutorial/winsock/winsock_tutorial_2.shtm" rel="nofollow">http://www.win32developer.com/tutorial/winsock/winsock_tutorial_2.shtm</a></p>
  
  <p>I have added some codes so it does recv(), in an infinite loop. My problem, if there is no data to read, it still does not block.</p>
  
  <p>Am I totally mistaken if I think recv should block in my case?</p>
  
  <p>The code I have added is:</p>
  
  <pre><code>for(;;)
  {
    char buffer[1000];
    memset(buffer,0,999);
    int inDataLength = recv(Socket,buffer,1000,0);
  
    int nError=WSAGetLastError();
    if(nError!=WSAEWOULDBLOCK&amp;&amp;nError!=0)
    {
      std::cout&lt;&lt;"Winsock error code: "&lt;&lt;nError&lt;&lt;"\r\n";
      std::cout&lt;&lt;"Client disconnected!\r\n";
  
      // Shutdown our socket
      shutdown(Socket,SD_SEND);
  
      // Close our socket entirely
      closesocket(Socket);
  
      break;
    }
  }
  </code></pre>
  
  <p>It is at the end, after the <code>std::cout&lt;&lt;"Client connected!\r\n\r\n";</code> line.
  I know I copied this from a "non blocking" example, but I dont think this code should do anything nonblocking really, still, my for loop is running like mad!</p>