【问题标题】:dotnet core create named pipes without "CoreFxPipe_" in file namedotnet core 创建文件名中没有“CoreFxPipe_”的命名管道
【发布时间】:2019-11-25 11:07:52
【问题描述】:

使用 dotnet 核心的 NamedPipeClientStreamNamedPipeServerStream 类创建命名管道时,关联的“管道”(实际上是一个套接字)添加了“CoreFxPipe_”自动到文件名的前面。

有没有一种简单的方法来防止这种行为?我只是希望文件名与我提供给构造函数的名称完全相同。

在dotnet coredocumentation中,描述了如下构造函数:

NamedPipeServerStream(String)
使用指定的管道名称初始化 NamedPipeServerStream 类的新实例。

但是,由于上述原因,这种描述充其量似乎具有误导性。

【问题讨论】:

    标签: c# ipc named-pipes


    【解决方案1】:

    解决方案:

    使用绝对路径作为管道名称

    详情:

    查看 NamedPipeClientStream 的源代码,第 93 行 显示管道名称已通过调用 GetPipePath 进行“规范化”,即PipeStream 类的方法。查看PipeStream的源代码,GetPipePath第35行实现。

    该方法似乎检查了“IsPathRooted”(大概;管道名称是绝对路径)。如果是,那么它将让您“完全控制”定义套接字的路径。否则,它会将套接字放在 /tmp/ 中,并在文件名中添加 CoreFxPipe_ 前缀。

    第 93 行 https://github.com/dotnet/corefx/blob/master/src/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.cs

    第 35 行https://github.com/dotnet/corefx/blob/master/src/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多