类似于“mkfifo”的命名管道创造,但双向

发布于 2024-08-03 06:13:35 字数 222 浏览 3 评论 0原文

我想创建一个命名管道,就像“mkfifo”创建的管道一样,但有一点需要注意。我希望管道是双向的。也就是说,我希望进程 A 写入 fifo,进程 B 从中读取,反之亦然。由“mkfifo”创建的管道允许进程 A 读取其写入管道的数据。通常我会使用两个管道,但我试图模拟一个实际设备,因此我希望 open()、read()、write() 等的语义尽可能与实际设备相似。有人知道一种无需借助两个管道或命名套接字即可完成此操作的技术吗?

I'd like to create a named pipe, like the one created by "mkfifo", but one caveat. I want the pipe to be bidirectional. That is, I want process A to write to the fifo, and process B to read from it, and vice-versa. A pipe created by "mkfifo" allows process A to read the data its written to the pipe. Normally I'd use two pipes, but I am trying to simulate an actual device so I'd like the semantics of open(), read(), write(), etc to be as similar to the actual device as possible. Anyone know of a technique to accomplish this without resorting to two pipes or a named socket?

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

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

发布评论

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

评论(2

失去的东西太少 2024-08-10 06:13:35

或者 pty(“伪终端接口”)。 man pty

Or pty ("pseudo-terminal interface"). man pty.

最好是你 2024-08-10 06:13:35

使用 Unix 域套接字。

哦,你说过你不想使用唯一可用的解决方案 - Unix 域套接字。

在这种情况下,您只能打开两个命名管道,或者不打开两个命名管道。当然,或者为它们编写您自己的设备驱动程序 - 无论如何,您可以为开源系统执行此操作;对于闭源系统(Windows、AIX、HP-UX)来说可能会更困难。

Use a Unix-domain socket.

Oh, you said you don't want to use the only available solution - a Unix-domain socket.

In that case, you are stuck with opening two named pipes, or doing without. Or write your own device driver for them, of course - you could do it for the open source systems, anyway; it might be harder for the closed source systems (Windows, AIX, HP-UX).

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