title: C++ WinSock error 10053
body: <p>Have problems with socket application. It must retrieve html start page from "ya.ru" many times, but immediately after the first time, I get socket error 10053.
  Please look at code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;winsock2.h&gt;
  int main()
  {
  WSADATA winsock_data;
  WSAStartup (MAKEWORD (2, 0), &amp;winsock_data);
  
  SOCKET socket_body;
  socket_body = socket (PF_INET, 1, 0);
  
  struct timeval to;
  to.tv_sec = 5000;
  to.tv_usec = 0;
  setsockopt(socket_body, SOL_SOCKET, SO_RCVTIMEO, (char *)&amp;to, sizeof(struct timeval));
  
  sockaddr_in destaddr;
  destaddr.sin_family = PF_INET;
  destaddr.sin_port = htons( 80 );
  destaddr.sin_addr.s_addr = inet_addr( "93.158.134.3" );
  connect ( socket_body, (struct sockaddr*)&amp;destaddr, sizeof(sockaddr) );
  
  char* buf = (char*)malloc(20000);
  int n;
  while(1)
  {
      send(socket_body, "GET / HTTP/1.1\r\nHost: ya.ru\r\n\r\n", 31, 0);
      Sleep(100);
      n = recv(socket_body, buf, 20000, 0);
      printf("%d, %d\n", GetLastError(), n);
      //if (n&gt;0) printf("%s", buf);
      Sleep(1000);
  }
  }
  </code></pre>
  
  <p>WSAStartup, socket(), setsockopt() and connect() doesn't cause errors. The firewall (as Windows firewall) and AV software isn't working. So the output is:</p>
  
  <pre><code>0, 8386
  0, 0
  10053, -1
  10053, -1
  ...
  </code></pre>
  
  <p>What's wrong with it and how it can be solved?</p>