我正在使用下面的代码片段从流中读取数据。在这里,我正在使用“ do-while”循环从流中读取数据以获取完整数据。
第二次执行循环时,以下读取操作将花费大约5到10秒:
numberOfBytesRead = API_SSL_Stream.Read(myReadBuffer, 0, iBufferSize);
有人可以告诉我代码片段中是否缺少某些内容吗?
byte[] myReadBuffer = new byte[iBufferSize];
int numberOfBytesRead = 0;
SSL_Stream.ReadTimeout = 50000;
SSL_Stream.ReadTimeout = 50000;
do
{
numberOfBytesRead = API_SSL_Stream.Read(myReadBuffer, 0, iBufferSize);
if (numberOfBytesRead > 0)
{
myCompleteNonSensitiveMessage.Append(
Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
bReadComplete = false;
}
else
{
bReadComplete = true;
}
} while (bReadComplete == false)`