This program establishes a client-server system that communicates through UNIX domain sockets. The client sends files to the server, which in turn saves these received files into a specific directory.
- Client communicates file details (name, size, content) to the server.
- Server saves received files to a specified directory.
- Graceful shutdown on both client and server with proper resource cleanup.
- Error handling for scenarios like missing files or server not running.
Functions:
__init__(inFileclass) - Initializes a File object with a name and content.save(inFileclass) - Saves the content of the file to a specified directory.signal_handler- Handles the SIGINT signal for graceful shutdown.clearSocket- Removes the domain socket file if it exists to ensure a clean startup.
Function:
signal_handler- Handles the SIGINT signal, informs the server about the client's exit and ensures graceful shutdown.
- Clone this repository.
- Navigate to the directory containing the program files.
- You will need 2 terminals at this directory one to run the server and one client
Server: python3 server.py <directory_to_save_files>
Client: python3 client.py <name of 1 or more files>
-
Server's ability to receive and save files:
-
Input:
python3 server.py ./test_directoryandpython3 client.py test.txt -
Expected Output: The content of
test.txtis saved in./test_directory/test.txt.
-
Input:
python3 client.py mountain.jpeg -
Expected Output: The image
mountain.jpegis saved in./test_directory/mountain.jpeg.
-
Input:
python3 client.py paint.jpg client.py -
Expected Output: The content of
paint.jpgandclient.pyis saved in./test_directory/paint.jpgand./test_directory/client.py.
-
-
Client's ability to handle non-existent files:
-
Client shutdown using ctrl-c:
-
Server shutdown using ctrl-c:
- Expected Output: "Shutting Down Server...
-
Client handling a non-running server:
- Server runs continuously, accepting file transmissions until interrupted by the user.
- Client can send multiple files in a single run.
- Client provides informative feedback for errors such as missing files or server not running.
- If the client is give no files in the argument, the client will ask the user once for files to input
- Files that already exist in the directory will be overwritten



