简体   繁体   English

Windows相当于Linux fifo

[英]Windows equivalent of Linux fifo

I use a function from a library that take a file name as parameter. 我使用来自库的函数,该函数将文件名作为参数。 In my application I receive the data from the network, so I can't feed the library with the downloaded data directly because I can't write it on the disk. 在我的应用程序中,我从网络接收数据,因此我无法直接向库中提供下载的数据,因为我无法在磁盘上写入数据。 To solve the problem I'm using Linux fifo (created with mkfifo() ) and I give the fifo name to the library. 为了解决这个问题,我正在使用Linux fifo(使用mkfifo()创建),并将fifo名称提供给库。

Now I have to port the code to Windows and I'm looking for an equivalent of Linux fifo mechanism. 现在我必须将代码移植到Windows,我正在寻找相当于Linux fifo机制。 I already tried Windows Named Pipe but these pipes can't be opened like regular files with standard library functions like fopen() (unless I'm missing something). 我已经尝试过Windows命名管道但这些管道不能像常规文件一样fopen() ,标准库函数如fopen() (除非我遗漏了什么)。

Do you know a Windows mechanism to read data from memory as a file ? 你知道一种Windows机制从内存中读取数据作为文件吗?

Named pipes are in fact what you want. 命名管道实际上就是你想要的。 If you want to use them with the C runtime, fread , fwrite and fclose use the _popen or _wpopen function to create the pipe. 如果要将它们与C运行时一起使用,则freadfwritefclose使用_popen_wpopen函数来创建管道。 On Windows, pipes are part of a separate namespace from file names. 在Windows上,管道是文件名的单独命名空间的一部分。 There is simply nothing you can pass to fopen that is equivalent. 没有什么可以传递给fopen ,这是等价的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM