title: Winsock2 - how to open a TCP socket that allows recv() with MSG_WAITALL?
body: <p>In this code:</p>
  
  <pre><code>// error checking is omitted
  
  // init Winsock2
  WSADATA wsaData;
  WSAStartup(MAKEWORD(2, 2), &amp;wsaData);
  
  // connect to server
  struct addrinfo *res = NULL, *ptr = NULL, hints;
  ZeroMemory(&amp;hints, sizeof(hints));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = IPPROTO_TCP;
  
  getaddrinfo(server_ip, "9999", &amp;hints, &amp;res);
  SOCKET client_socket = socket(res-&gt;ai_family, res-&gt;ai_socktype, res-&gt;ai_protocol);
  
  connect(client_socket, res-&gt;ai_addr, (int)res-&gt;ai_addrlen);
  
  freeaddrinfo(res);
  res = NULL;
  
  // read the data
  unsinged int size1;
  if (recv(client_socket, (char*)&amp;size1, sizeof(int), MSG_WAITALL) == SOCKET_ERROR)
  {
      return WSAGetLastError();
  }
  </code></pre>
  
  <p>(note the <code>MSG_WAITALL</code> flag in <code>recv()</code>) everything works fine, expect for <code>recv()</code>. <code>WSAGetLastError()</code> returns <code>WSAEOPNOTSUPP</code>.<br>
  MSDN states that</p>
  
  <blockquote>
    <p>Note that if the underlying transport does not support MSG_WAITALL, or if the socket is in a non-blocking mode, then this call will fail with WSAEOPNOTSUPP. Also, if MSG_WAITALL is specified along with MSG_OOB, MSG_PEEK, or MSG_PARTIAL, then this call will fail with WSAEOPNOTSUPP. This flag is not supported on datagram sockets or message-oriented sockets.</p>
  </blockquote>
  
  <p>But it doesn't look like I'm doing something from this list. Why my <code>recv()</code> call doesn't work?</p>