This system facilitates file management between a client and a server using a socket-based connection. It supports operations such as uploading, downloading, navigating directories, and managing files.
Changes the current working directory (CWD) of the client.
- Usage:
cd <path>- Relative path (
./subdir) - Parent directory (
../)
- Relative path (
- Parameters:
client_socket: The client’s socket connection.cwd: Current working directory.arg: Path argument.
- Output: Updates the current working directory.
Lists the contents of the current directory.
- Usage:
ls - Parameters:
client_socket: The client’s socket connection.cwd: Current working directory.
- Output: Displays directory contents, highlighting folders in green.
Uploads a file from the client to the server.
- Usage:
upload <file_path> - Parameters:
client_socket: The client’s socket connection.path: Path to the file on the client.cwd: Current working directory on the server.
- Features:
- Checks if the file exists locally.
- Prompts for overwrite if the file exists on the server.
- Sends file data in chunks with a termination signal (
EOF).
Downloads a file from the server to the client.
- Usage:
download <file_name> - Parameters:
client_socket: The client’s socket connection.file_name: Name of the file to download.cwd: Current working directory on the server.
- Features:
- Saves the file to the client’s default download directory.
Deletes a file on the server.
- Usage:
rm <file_name> - Parameters:
client_socket: The client’s socket connection.file_name: Name of the file to delete.cwd: Current working directory.
- Output: Confirms file deletion or reports an error.
Creates a new directory on the server.
- Usage:
mkdir <directory_name> - Parameters:
client_socket: The client’s socket connection.name: Name of the directory to create.cwd: Current working directory.
- Output: Confirms directory creation or reports an error.
Deletes a directory on the server.
- Usage:
rmdir <directory_name> - Parameters:
client_socket: The client’s socket connection.name: Name of the directory to delete.cwd: Current working directory.
- Output: Confirms directory deletion or reports an error.
Terminates the client program.
- Usage:
exit - Functionality:
- Closes the socket connection and exits the loop.
BUFFER_SIZE: Controls the size of data chunks exchanged between client and server (default: 1024 bytes).TIMEOUT: Specifies the socket timeout (default:None).