title: An Socket error occurs while using WSAEventSelect in C#
body: <p>a problem happened will i was using WSAEventSelect function to handle network event, code as below:<br/>  </p>
  
  <pre><code>AutoResetEvent[] EventArray = new AutoResetEvent[1];
  
  AutoResetEvent clientEvent = new AutoResetEvent(false);
  EventArray[0] = clientEvent; 
  
  if (NetWork.WSAEventSelect(m_clientSocket, EventArray[0], NetWork.FD_READ | NetWork.FD_CLOSE) == -1)
  // (m_clientSocket is passed by another function which presents the client socket: m_clientSocket = Socket.EndAccept(ar))
  {Console.WriteLine("Get Last Error: {0}",NetWork.WSAGetLastError());}
  </code></pre>
  
  <p>The Definition of WSAEventSelect is: <br/></p>
  
  <pre><code>[DllImport("Ws2_32.dll")]
  public static extern int WSAEventSelect(Socket s, EventWaitHandle e, int eventType);
  </code></pre>
  
  <p>Also the define of FD_READ and FD_CLOSE are:</p>
  
  <pre><code>public const int FD_READ_BIT = 0;
  public const int FD_READ = (1 &lt;&lt; FD_READ_BIT);
  public const int FD_CLOSE_BIT = 5;
  public const int FD_CLOSE = (1 &lt;&lt; FD_CLOSE_BIT);
  </code></pre>
  
  <p>the return error of the WSAEventSelect function is -1 with last error: 10038 known as: WSAENOTSOCK</p>
  
  <p>Please advice </p>
  
  <p>Thanks</p>