The server application MUST be implemented in server.py Python file, accepting two command-line arguments:

computer science

Description

Server Application Specification

The server application MUST be implemented in server.py Python file, accepting two command-line arguments:

$ ./server.py <PORT> <FILE-DIR>

  • <PORT>: port number on which server will listen on connections. The server must accept connections coming from any interface.
  • <FILE-DIR>: directory name where to save the received files.

For example, the command below should start the server listening on port 5000 and saving received files in the directory /save.

$ ./server.py 5000 /save

Requirements:

  • The server must open a listening socket on the specified in the command line port number
  • The server should gracefully process an incorrect port number and exit with a non-zero error code (you can assume that the folder is always correct). In addition to exit, the server must print out on standard error (using sys.stderr.write()) an error message that starts with ERROR: string.
  • The server should exit with code zero when receiving SIGQUIT/SIGTERM signal
  • The server should be able to accept and process multiple connection from clients at the same time
  • The server must count all established connections (1 for the first connect, 2 for the second, etc.). The received file over the connection must be saved to <FILE-DIR>/<CONNECTION-ID>.file file (e.g., /save/1.file/save/2.file, etc.). If the client doesn’t send any data during gracefully terminated TCP connection, the server should create an empty file with the name that corresponds to the connection number.
  • The server must assume an error if no data received from the client for over 10 seconds. It should abort the connection and write a single ERROR string (without end-of-line/carret-return symbol) into the corresponding file. Note that any partial input must be discarded.
  • The server should be able to accept and save files up to 100 MiB

 

Client Application Specification

The client application MUST be implemented in client.py file, accepting three command-line arguments:

$ ./client.py <HOSTNAME-OR-IP> <PORT> <FILENAME>

  • <HOSTNAME-OR-IP>: hostname or IP address of the server to connect
  • <PORT>: port number of the server to connect
  • <FILENAME>: name of the file to transfer to the server after the connection is established.

For example, the command below should result in connection to a server on the same machine listening on port 5000 and transfer content of file.txt:

$ ./client.py localhost 5000 file.txt

Requirements:

  • The client must be able to connect to the specified server and port, transfer the specified file, and gracefully terminate the connection.
  • The client should gracefully process incorrect hostname and port number and exit with a non-zero exit code (you can assume that the specified file is always correct). In addition to exit, the client must print out on standard error (using sys.stderr.write()) an error message that starts with ERROR: string.
  • Client application should exit with code zero after successful transfer of the file to server. It should support transfer of files that are up to 100 MiB file.
  • Client should handle connection and transmission errors. The reaction to network or server errors should be no longer that 10 seconds:
    • Timeout to connect to server should be no longer than 10 seconds
    • Timeout for not being able to send more data to server (not being able to write to send buffer) should be no longer than 10 seconds.

Whenever timeout occurs, the client should abort the connection, print an error string starting with ERROR: to standard error (using sys.stderr.write()), and exit with non-zero code.


Related Questions in computer science category