title: CAsyncSocket::Receive returns WSAENOTSOCK
body: <p>I use a trivial CAsyncSocket to implement a TCP server. I cannot see any mistake here. Still, Receive returns WSAENOTSOCK:</p>
  
  <pre><code>class CMyWnd : CWnd
  {
    CMySock m_sListener;
    CMySock m_sConnected;
  }
  
  
  CMyWnd::CMyWnd()
  {
    m_sListener.SetWnd(this);
    m_sConnected.SetWnd(this);
    // ...
    m_sListener.Create(56999, SOCK_STREAM, FD_READ | FD_WRITE | FD_ACCEPT | FD_CLOSE, _T("127.0.0.1"));
    if(m_sListener.Listen() == FALSE) { exit(1)] }
  }
  
  
  void CMyWnd::OnReceive(void)
  {
    TCHAR p[MAX_MSGLEN];
    memset(p, 0, sizeof(p));
    int nRead;
    nRead = m_sConnected.Receive(p, MAX_MSGLEN);
    if(nRead == SOCKET_ERROR)
    {
      UINT dwErr = GetLastError(); // returns WSAENOTSOCK!!
    }
  }
  
  void CMyWnd::OnAccept(void)
  {
    m_sListener.Accept(m_sConnected);
  }
  </code></pre>
  
  <p>The CMySock is just trivially inherited from CAsyncSock and passes to the window class:</p>
  
  <pre><code> void CMySock::OnAccept(int nErrorCode)
   {
     if(m_pWnd &amp;&amp; nErrorCode==0)
     {
       m_pWnd-&gt;OnReceive();
     }
     CAsyncSocket::OnAccept(nErrorCode);
   }
  
   void CMySock::OnReceive(int nErrorCode)
   {
     if(m_pAgentWnd &amp;&amp; nErrorCode==0)
     {
       m_pWnd-&gt;OnReceive();
     }
     CAsyncSocket::OnReceive(nErrorCode);
   }
  </code></pre>
  
  <p>It's impossible that this returns WSAENOTSOCK here because it MUST be a socket! It is returned by accept iself and I also receive the notification when data is received.</p>