I am building a server that communicates through FIFO with it's clients.
So far I've managed to create a FIFO, run a new thread, once a message arrives in the FIFO and output the message from the thread.
The problem is that as soon as the client writes something in the pipe, the server just prints the message endlessly (I am reading from the pipe in a while(1)
).
My question is: shouldn't the read
operation also remove the message from the pipe, so it doesn't get read again? Isn't that the point of First In, First Out? Is that something I have to do manually?
Here's my code too, if that helps: http://pastebin.com/Ag7vgrav
What I do to write in the FIFO is just: echo test > /home/ubuntu/work/my_fifo