public SecureChannelPacket(Stream s) { _code = (SecureChannelCode)s.ReadByte(); if (_code == SecureChannelCode.None) { byte[] buffer = new byte[2]; OffsetStream.StreamRead(s, buffer, 0, 2); ushort dataLen = BitConverter.ToUInt16(buffer, 0); if (dataLen > 0) { _data = new byte[dataLen]; OffsetStream.StreamRead(s, _data, 0, _data.Length); } else { _data = new byte[] { }; } } else { throw new SecureChannelException(SecureChannelCode.RemoteError, null, null, "Remote client sent an error response code: " + _code.ToString()); } }
public SecureChannelHandshakePacket(Stream s) { int code = s.ReadByte(); if (code == -1) { throw new EndOfStreamException(); } _code = (SecureChannelCode)code; if (_code != SecureChannelCode.None) { throw new SecureChannelException(SecureChannelCode.RemoteError, null, null, "Remote client sent an error response code: " + _code.ToString()); } }