views:

61

answers:

4
+2  Q: 

mkfifo Alternative

Hi there,

I have a process that continuously needs to write information. Furthermore, there is a second process which sometimes connects to the "information channel" of the writing process and should read the information that are written since it's connected. This process might also deconnect and reconnect several times again.

I am currently realizing this with a named pipe, by using mkfifo() in my c++ program. Unfortunately if I call open() on this fifo it blocks until a process opens the fifo for reading. This is quite normal for named pipes, but I need this open command to be non-blocking.

Do you know an alternative to mkfifo in this case?

Heinrich

A: 

You can use shared memory or mmap. It should contain offset to the oldest data, and the block of memory for data

fifo is limited to 64k (depends on distribution and some settings).

VJo
+1  A: 

You could use Unix-domain sockets, or regular TCP sockets on loopback interface.

el.pescado
Thats not a solution because my writer which is the server will have to wait for a client before sending and will be stuck in the accept() method.
Heinrich
You can use non-blocking I/O using `O_NONBLOCK` `fcntl` flag, and `select`/`poll` function.
el.pescado
A: 

Asio C++ Library

plan9assembler
A: 

I finally used the unix message queue, Reader and Writer can.be started totally independet and everything can be performed non blocking

Heinrich