title: WSAGetLastError returns 10038 while trying to get data using Telnet
body: <p>I have a program sends data using telnet. By using putty i can get data.</p>
  
  <p>But in my code i use same conenction prefs ( Same ip = 127.0.0.1, Same port = 27021)</p>
  
  <p>But i get WSAENOTSOCK ( 10038 ) error.</p>
  
  <p>Here is my code:</p>
  
  <pre><code> WSADATA WSAData;
  SOCKADDR_IN sin;
  SOCKET sock;
  WSAStartup( MAKEWORD( 2, 2 ), &amp;WSAData );
  
  
  sock = WSASocket( AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 0, 0 );
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = htonl(INADDR_ANY);
  sin.sin_port = htons( 27021 );
  
  
  bind( sock, ( SOCKADDR * )&amp;sin, sizeof( sin ) );
  listen( sock, SOMAXCONN );
  int sin_len=sizeof(sin);
  
  while( true )
  
     {
      SOCKET tmp = accept( sock, NULL, NULL );
      char buff[ 1024 ];
  
  int result = recv(tmp, buff, 1024, 0);
  
   std::cout&lt;&lt;buff&lt;&lt;" "&lt;&lt;result&lt;&lt;" "&lt;&lt;WSAGetLastError()&lt;&lt;std::endl;
      closesocket( tmp );
  }
  return( 0 );
  }
  </code></pre>
  
  <p>It returns -1 as result and 10038 as wsagetlasterror.</p>
  
  <p>EDIT: If I use sin.sin_addr.s_addr = htonl(INADDR_ANY); i get error codes but if I use sin.sin_addr.s_addr = inet_addr("127.0.0.1") no data received.</p>