private void ProcessAlert()
{
while (alertQueue.Available >= 2)
{
/*
* An alert is always 2 bytes. Read the alert.
*/
byte[] tmp = new byte[2];
alertQueue.Read(tmp, 0, 2, 0);
alertQueue.RemoveData(2);
byte level = tmp[0];
byte description = tmp[1];
if (level == (byte)AlertLevel.fatal)
{
/*
* This is a fatal error.
*/
this.failedWithError = true;
this.closed = true;
/*
* Now try to Close the stream, ignore errors.
*/
try
{
rs.Close();
}
catch (Exception)
{
}
throw new IOException(TLS_ERROR_MESSAGE);
}
else
{
/*
* This is just a warning.
*/
if (description == (byte)AlertDescription.close_notify)
{
/*
* Close notify
*/
this.FailWithError(AlertLevel.warning, AlertDescription.close_notify);
}
/*
* If it is just a warning, we continue.
*/
}
}
}