polling for socket Read.
According to the : MSDN socket polling method SelectRead returns true on 3 occasions but I'm only interested in just the one; when there's data available for reading. Is there a way to poll a socket in C# so that I read the buffer only when this condition is satisfied?
so far my method is:
private void recvMessage(ref TextBox mDest)
if (m_sock.Poll(-1, SelectMode.SelectRead))
rcount = m_sock.Receive(recvBuffer);
mDest.Text += Encoding.ASCII.GetString(recvBuffer);
Array.Clear(recvBuffer, 0, recvBuffer.Length);
mDest.Text += "\r\n";
SendMessage(mDest.Handle, WM_VSCROLL, (IntPtr)SB_BOTTOM, IntPtr.Zero);
mDest.Text = "";
catch (SocketException se)
According to MSDN I wouldn't see why your method wouldn't work. Whenever something is true of the socket based on SelectMode.SelectRead, your thread will wakeup and call Receive.
It works, but I only want it to wake up only when there's something to read in the buffer.