Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In this section, we present a simple client-server application that employs FIFOs for IPC. The server provides the (trivial) service of assigning unique sequential numbers to each client that requests them. In the course of discussing this application, we introduce a few concepts and techniques in server design.
In the example application, all clients send their requests to the server using a single server FIFO. The header file (Example 44-6) defines the well-known name (/tmp/seqnum_sv) that the server uses for its FIFO. This name is fixed, so that all clients know how to contact the server. (In this example application, we create the FIFOs in the /tmp directory, since this allows us to conveniently run the programs without change on most systems. However, as noted in Section 38.7, creating files in publicly writable directories such as /tmp can lead to various security vulnerabilities and should be avoided in real-world applications.)