Win32:匿名管道上的事务

发布于 2024-09-24 13:03:43 字数 334 浏览 1 评论 0原文

TransactNamedPipe 函数 的文档声称“此参数也可以是句柄到一个匿名管道,由 CreatePipe 函数返回。” 这意味着可以在匿名管道上使用事务。据我了解,事务是读/写操作,匿名管道要么是读,要么是写——这对我来说没有意义。

  1. 真的可以使用匿名管道进行事务吗?
  2. 如果是,怎么办?例如,我应该将通过调用 CreatePipe 获得的两个句柄中的哪一个传递给 TransactNamedPipe?

Documentation for TransactNamedPipe Function claims that "This parameter can also be a handle to an anonymous pipe, as returned by the CreatePipe function."
This would mean that it is possible to use transactions on anonymous pipes. As I understand it transactions are read/write operations and anonymous pipes are either read or write - it doesn't make sense to me.

  1. Is it really possible to use transactions with anonymous pipes?
  2. If yes, how? For example which of the two handles obtained from call to CreatePipe should I pass to TransactNamedPipe?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对岸观火 2024-10-01 13:03:43

警告:我还没有尝试过这个。然而 CreatePipe 的 MSDN 文档包含确凿的证据来说明为什么这可能有效。这些文档目前已经非常成熟 - 命名管道是一种非常早期的 Windows 传输 - 如果这是不正确的,我会感到惊讶。

匿名管道是使用以下方式实现的
具有唯一名称的命名管道。
因此,你经常可以传递一个句柄
到函数的匿名管道
需要一个命名的句柄
管道。

结合您上面提供的报价,这表明这是可行的。不确定您将使用 CreatePipe 中的哪个句柄(读取或写入) - 也许两者都可以工作,因为这是一个在幕后的单个双工命名管道。

Caveat: I have not tried this. However the MSDN docs for CreatePipe contain corroborative evidence for why this might work. These docs are very mature at this point - named pipes were a very early Windows transport - and it would surprise me if this is incorrect.

Anonymous pipes are implemented using
a named pipe with a unique name.
Therefore, you can often pass a handle
to an anonymous pipe to a function
that requires a handle to a named
pipe.

This, in combination with the quote you provided above, suggests this will work. Not sure what handle (read or write) from CreatePipe you would use - maybe either will work, since this is a single duplex named pipe under the covers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文