UWP 中的 IBuffer 用于 TCP 消息



我需要通过TCP连接传输一个字符串。为此,我可以一次序列化我的对象(超过 10000 行列表(,没有预期。但是大字符串不会传输(据我了解,由于缓冲区大小(。所以MSDN,在这个页面(https://learn.microsoft.com/ru-ru/windows/uwp/networking/sockets(上说我使用IBuffer来转移我的分割笔画。这是一个代码:

// More efficient way to send packets.
// This way enables the system to do batched sends
IList<IBuffer> packetsToSend = PreparePackets();
var outputStream = stream.OutputStream;
int i = 0;
Task[] pendingTasks = new Tast[packetsToSend.Count];
foreach (IBuffer packet in packetsToSend)
{
 pendingTasks[i++] = outputStream.WriteAsync(packet).AsTask();
}
 // Now, wait for all of the pending writes to complete
  await Task.WaitAll(pendingTasks);

PraparePackets((的方法是什么?如何准备中风的包装?

编辑:我找到了DataReader和DataWriter的解决方案,它们用Albahari编写。(16章完(。

我找到了用Albahari编写的DataReader和DataWriter的解决方案。16章完(。

最新更新