There is a coding error in the server's while loop - the server will never exit the loop even when there is an error or the server receives eof on the FIFO. It should be changed to something like this:
while(1)
{
if((bytesread = read( fd, buf, MAX_BUF - 1)) > 0)
{
buf[bytesread] = '\0';
printf("Received: %s\n", buf);
}
else
break;
}
Your other problem is that your client sends a single line and then closes the FIFO. The server reads until EOF. So it is going to read the single line, then hit EOF because the client closed. This is completely normal.
Where it becomes a problem is when you want your server to provide service to multiple clients. In that case you don't want to quit reading after every individual client closes its end. The semantics are such that the server will only see EOF after the last of all clients close. So an easy way to accommodate the server handling multiple clients is to open your server-side FIFO as read/write. Then there will always be a "writer", the server itself, with write end of the FIFO open. This will prevent the server from seeing EOF until you decide to shut it down.
A second problem is that you need to read and write in loops. You are not guaranteed to get your full data request filled in one call.
Also, having the client create the FIFO that the server reads is an odd approach. Normally you want the server to create a known FIFO to which clients connect.