public virtual int BeginRead()
{
if (rlock.IsHeldByCurrentThread ()) {
throw new IOException ("BeginRead is not reentrant");
}
#if AGNOS_TRANSPORT_DEBUG
System.Console.WriteLine("TransportBegin.BeginRead");
#endif
rlock.Acquire ();
try {
int seq = readSInt32(inStream);
int packetLength = readSInt32(inStream);
int uncompressedLength = readSInt32(inStream);
#if AGNOS_TRANSPORT_DEBUG
System.Console.WriteLine(">> seq={0}, len={1}, uncomp={2}", seq, packetLength, uncompressedLength);
#endif
if (readStream != null) {
throw new InvalidOperationException ("readStream must be null at this point");
}
readStream = new BoundInputStream (inStream, packetLength, true, false);
if (uncompressedLength > 0) {
readStream = new BoundInputStream (new DeflateStream (readStream, CompressionMode.Decompress, false), packetLength, false, true);
}
return seq;
} catch (Exception) {
readStream = null;
rlock.Release ();
throw;
}
}