internal int ReadApplicationData(byte[] buf, int offset, int len)
{
while (applicationDataQueue.Available == 0)
{
if (this.closed)
{
/*
* We need to read some data.
*/
if (this.failedWithError)
{
/*
* Something went terribly wrong, we should throw an IOException
*/
throw new IOException(TLS_ERROR_MESSAGE);
}
/*
* Connection has been closed, there is no more data to read.
*/
return 0;
}
SafeReadData();
}
len = System.Math.Min(len, applicationDataQueue.Available);
applicationDataQueue.Read(buf, offset, len, 0);
applicationDataQueue.RemoveData(len);
return len;
}