We know TCP doesn't preserve message boundary but UDP does. But what is the case with pipe and FIFO? For example, Suppose we have a server and two clients on the same host, server creates a FIFO using a well known pathname, and open this FIFO for read. Client 1 and client 2 both open this FIFO for write. And following events occur:
server read this FIFO with sufficient large buffer, like:
char buf[1024];
read(fifofd, buf, sizeof(buf));
My question is: How much data will step 3 return? Does it just return the first 100 bytes sent by client 1, so we don't have to worry about message boundary? Or does it return all the 200 bytes, so we have to separate message from client1 and message from client 2?
You'll get all the data (200 bytes) with client 1's data then client 2's.
There is no concept of a message, just reading and writing bytes.