protected virtual Int32 DataSocketReceiveWhatsAvaiable(Byte[] buffer, Int32 offset, Int32 size)
{
this.StartTimeoutTimer();
try
{
Int32 lReadBytes = DataSocket.Receive(buffer, offset, size, SocketFlags.None);
if (lReadBytes == 0)
this.DataSocket.Close();
this.TriggerOnBytesReceived(lReadBytes);
return lReadBytes;
}
catch (ObjectDisposedException)
{
this.DataSocket.Close();
return 0;
}
catch (SocketException)
{
this.DataSocket.Close();
return 0;
}
finally
{
this.StopTimeoutTimer();
}
}