【问题标题】:Trying to understand IDuplexPipe试图了解 IDuplexPipe
【发布时间】:2022-01-13 20:59:51
【问题描述】:

我正在开发一个围绕Binance's web socket stream 的网络套接字包装器。 System.IO.Pipelines 对我来说看起来很有趣,因为它 solves 的问题。

我很可能会采用以下实现之一:

我无法理解IDuplexPipePipe 之间的区别。

IDuplexPipe 是支持读写的类型的协定。例如,网络连接将由 IDuplexPipe 表示。

由于我正在处理的网络套接字包装器与币安的网络套接字流有关,我假设我需要IDuplexPipe

SignalR 使用 IDuplexPipe,而 DotNet.Interactive.PowerShell 仅使用 Pipe 类。您能否通过现实生活中的示例说明这两者之间的区别是什么,因为我不太了解Microsoft's documentation 的含义。

【问题讨论】:

    标签: c# .net-core websocket system.io.pipelines


    【解决方案1】:

    IDuplexPipe 文档:

    定义一个提供双工管道的类,可以从中读取和写入数据。

    IDuplexPipe 是一个接口,表示您可以使用 PipeReader 读取和使用 PipeWriter 写入的内容。
    IO.Pipelines 管道只是一个缓冲区。

    您链接的文档中对此进行了解释:https://docs.microsoft.com/en-us/dotnet/standard/io/pipelines#pipe

    Pipe 类可用于创建 PipeWriter/PipeReader 对。写入 PipeWriter 的所有数据都在 PipeReader 中可用: PipeWriter 将数据写入缓冲区,PipeReader 从中读取数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-17
      • 2020-01-05
      • 2014-03-06
      • 1970-01-01
      相关资源
      最近更新 更多