2

我正在 WinRT/Metro 应用程序中使用 StreamSocket.InputStream.ReadAsync() 进行字节读取,并且需要知道实际读取了多少字节。此读取被视为同步读取,并且必须保持同步读取。

这是相关的代码片段:

var receivedTask = this._socket.InputStream.ReadAsync(buffer.AsBuffer(), length, Windows.Storage.Streams.InputStreamOptions.None);
receivedTask.AsTask().Start();
receivedTask.AsTask().Wait(timeout);
// Need code here to get the number of bytes received

if (receivedBytes > 0)
{
    receivedTotal += receivedBytes;
    continue;
}
else
{
    // Socket Closed
}
4

0 回答 0