This homework will require you to write a C or C++ application that can run in one of two different modes: as a client or as a server (use a command switch). When running as the server, the process must create a FIFO and print the name for it. When running as a client, the process must request the name of the server and then ”connect” to it. The client then sends shell commands to execute to the server and the server must respond with the command output (standard out). Additonally, there is a list of commands that the client must support. The application must perform the requirements below.
- You shall submit all source code and a makefile in a tar file. (a) The makefile shall be able to build your source in a 32 bit PeppermintOS VM.
- The program shall support two modes of operation: server and client. These two modes should be specified via a command switch.
- The program shall indicate how to start the program in each mode. This only needs to be done if no valid command argument is specified.
- The server shall create a uniquely named FIFO when it starts. The name of the FIFO must be less than 16 characters and it has to be different each time the server runs. You must support multiple running servers at a time.
- The server shall print the name of the FIFO when it starts. This name will then be used by the client.
- The server shall create a Message Queue. This queue should be reasonably unique to the server and the client will need to know its name somehow. 1
- The server shall read commands from the message queue and perform the following actions: (a) If the quit command is sent, the server shall terminate, cleaning up resources as appropriate. (b) If the help command is sent, the server shall print the name of it’s FIFO and it’s process ID. (c) If the shell command is sent, the server shall execute a specified shell command. The shell command should be transmitted to the server as part of the message.
- Each message in the queue shall contain all the necessary information to perform its action.
- The output of each shell command executed by the server shall be written to the FIFO.
- The server shall clean up any FIFO or Message Queue that it creates.
- The client shall accept the name of the FIFO on the command line.
- The client shall print all data in the FIFO to standard out.
- The client shall read commands from standard in continuously as follows: (a) If the user enters the exit command, the client shall terminate. (b) If the user enters the server quit command, the client shall send the quit command to the server. (c) If the user enters the help command, the client shall send the help command to the server as well as print out client help information. (d) If the user enters the shell command, the client shall send the user specified command to the server for execution. The user should then be able to enter the command. You can allow them to be entered together (shell ls) or prompt again for the command.
- The client shall only send the quit command to the server when the user specifically requests it to be sent.
- The client shall terminate if the server specified is not running. You should not attempt to keep sending commands to a server that has terminated. The client should terminate if it is unable to send commands or read results. This should work even if the server abnormally terminates.
- The client shall be able to receive commands even when printing out information from the FIFO. Printing the FIFO contents should not delay reading commands from the user and vice versa.