private void CheckResponse(SCPChannelStream stream)
{
byte response = stream.ReadByte(_protocolTimeout);
if (response == 0) {
// OK
return;
}
if (response == 1 || response == 2) {
// Warning or Error
// followed by a message which is terminated by LF
byte[] messageData = stream.ReadUntil(LF, _protocolTimeout);
string message = _encoding.GetString(messageData, 0, messageData.Length - 1);
throw new SCPClientException(message);
}
throw new SCPClientException("Invalid response");
}