write a file sharing system. Two files are needed to be written i.e. client.cpp and server.cpp
Server.cpp:
It should allocate a shared memory and then wait until some client writes a command into the shared memory. Command can be of two formats:
i) read filename
ii) write filename data
Read that command, clear the shared memory, and make a new thread.
If command is of read, make a new shared memory and share the key with the client process through old shared memory. Then copy the content of that file onto new shared memory.
If command is of write, copy the contents of the command onto file of specified name.
5)Use the semaphores to avoid any unwanted situation.
Client.cpp:
It should read the command from terminal, make sure it is in right format.
It should wait until there is no other writer or reader for shared memory. (Use semaphore)
And then it will write the command to the shared memory
If command is of read, wait until the response, and communicate with server to show the content of the file, then terminate.
If command is of write just terminate the process.