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:
Code:
private void recvMessage(ref TextBox mDest)
{
try
{
int rcount;
if (active_connection)
{
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);
}
else
mDest.Text = "";
}
catch (SocketException se)
{
MessageBox.Show(se.Message);
}
}