Код:
private void OnReceiveCallbackStatic(IAsyncResult result)
{
int rs = 0;
try
{
rs = _stream.EndRead(result);
if (rs > 0)
{
byte Length = _buffer[0];
if (_stream.DataAvailable)
{
_buffer = new byte[Length + 2];
_stream.BeginRead(_buffer, 0, Length + 2, new AsyncCallback(OnReceiveCallback), result.AsyncState);
}
}
}
catch
{
// close();
}
}Code: C#