CS计算机代考程序代写 scheme python c/c++ compiler Java c++ 2021/11/3 上午10:23 Programming Assignment

2021/11/3 上午10:23 Programming Assignment

https://canvas.cityu.edu.hk/courses/42813/assignments/177986 1/8

Programming Assignment

Due Monday by 11:59pm Points 6 Submitting a file upload
File Types py, c, cc, cpp, txt, and java Available Oct 18 at 12am – Nov 8 at 11:59pm 22 days

Start Assignment

Source code of the server in python
Instructions for installing the server program (html)

Remote File Storage Client using C/C++ or Python

Table of Contents

1. Project Description
2. Development Environment
3. Project Demo
4. List of Tasks
5. Project Requirements and Tutorials
6. Code Quality
7. Assessment Tool
8. Submission
9. Getting Help

1. Project Description

In this project, you will need to implement the client of a remote file storage system. The remote file
storage is a client-server application, where clients can upload, download, and retrieve files from a
server. The server runs on a specified port and supports 3 commands executed by the client: UPLOAD,
DOWNLOAD, RETRIEVE.

UPLOAD: this command allows the client to upload a text file to the server. The uploading information
includes the IP address and port number of the server, and the to-be-uploaded text file name. If the file is
already in the server, the uploading procedure exits, and prints out “SUCCESS –the file is there”;
otherwise, the file will be uploaded to the server line-by-line until the last line with # , assuming that the
file ends at a line with # only.

https://canvas.cityu.edu.hk/courses/42813/files/8247712/download
https://canvas.cityu.edu.hk/courses/42813/files/folder/Programming%20Assignment?preview=8240493

2021/11/3 上午10:23 Programming Assignment

https://canvas.cityu.edu.hk/courses/42813/assignments/177986 2/8

DOWNLOAD: this command allows the client to download a named text file from the server. The
downloading information includes the IP address and port number of the server, and the name of to-be-
downloaded text file. If the file does not exist in the server, the downloading procedure exits, printing out
“FAIL–the file does not exist”; otherwise, the file will be downloaded line-by-line until the last line with #
only, and the downloaded file will be saved in a local directory with the same file name.

RETRIEVE: this command allows the client to retrieve whether a named text file does exist in the server.
The retrieving information includes the IP address and port number of the server, and the retrieving file
name. If the named text file is in the server, return “YES”; otherwise return “No”.

Notice that the commands UPLOAD and DOWNLOAD share similar coding, you may recycle some
code from one command implementation to the implementation of another command. The
implementation code of the RETRIEVE command may also be used in the implementation of commands
UPLOAD and DOWNLOAD, too.

Assume that the server is already running on 192.168.0.1 port 16000. The user starts the client by
running the command ./RemoteFileStorage 192.168.0.1 16000
in the terminal (Linux/macOS), or by double-clicking on the compiled executable RemoteFileStorage.exe
(Windows). After establishing the TCP connection to the socket of the server, the client program will
repeatedly ask the user to input a command to execute. The server program is provided to you and
can be found in the project demo file. You only need to implement the client program. Name your
client RemoteFileStorage.

For command RETRIEVE, the client will just send the command name and file name to the server,
whereas for UPLOAD, the client will send a message that contains the command name (i.e. UPLOAD)
and the file name, the handling of DOWNLOAD command is similar to the one for the UPLOAD
command. Below is a possible communication sequence between a client and the server for first
uploading a file named as “textfile” and then downloading the file :

client: UPLOAD textfile

server: SUCCESS

client: DOWNLOAD teatfile

server: FAIL (ERROR – the file cannot be found)

client: DOWNLOAD textfile

server: SUCCESS

Your code for UPLOAD/DOWNLOAD commands should print out useful information, e.g., the
information with DOWNLOAD can be formatted as follows.

2021/11/3 上午10:23 Programming Assignment

https://canvas.cityu.edu.hk/courses/42813/assignments/177986 3/8

IP Address: xxx.xxx.xxx.xxx Port Number: yyyyy

Connect status: SUCCESS/FAIL

Input the file name to be requested from the server: FileName

Send status: SUCCESS/FAIL

Open file status: SUCCESS/FAIL

Received text: zzz

Save text status: SUCCESS/FAIL

where the number xxx.xxx.xxx.xxx and yyyyy are the IP Address and Port Number respectively, which
are given as input parameters. The string FileName is the name of the file in the server which is read
from the input. The string zzz represents the text line of the file received from the server. Once the client
receives the text line, it needs to save it in a file named as FileName locally.

As for the DOWNLOAD command, the server program sends the text line-by-line continuously until the
entire file content has been sent out, and the last line of each text file consists of a single # character.
Therefore, a loop is needed in your program to receive the text as shown in the following pseudo code
fragment.

while (the current line <> ‘#’){

/* code for receiving the text from the server */

/* code for saving the text in the file */

}

The handling for uploading a text file from the client side can be done similarly.

2. Development Environment

Hardware:

Two connected computers.

If you use two laptops:
if you are in CityU, you can connect the two laptops to the campus wireless network so that they
can communicate with each other (How to do this? Links to an external site.
(http://www.cityu.edu.hk/csc/deptweb/facilities/ctnet/wlan/wlanmain.htm) ).

http://www.cityu.edu.hk/csc/deptweb/facilities/ctnet/wlan/wlanmain.htm

2021/11/3 上午10:23 Programming Assignment

https://canvas.cityu.edu.hk/courses/42813/assignments/177986 4/8

if the campus wireless network is not available, you can set up a Wi-Fi ad-hoc network (How to
do this?(Links to an external site.)
(http://compnetworking.about.com/od/wireless/ht/setupadhocwifi.htm) ).

If you use two desktops, you can directly connect the computers using cables and configure them in
a subnet (How to do this?(Links to an external site.) (http://www.home-network-
help.com/crossover.html) ).

If you do not have access to two computers, it is suggested to install a virtual machine to test your
program (How to do this? (https://canvas.cityu.edu.hk/courses/42813/files/8244161/download?
download_frd=1) ).

Software:

You can choose to code the client in either C/C++ (recommended), Java, or Python, based on your own
preference and familiarity.

If you use MS Windows:
for C/C++: Visual Studio: https://visualstudio.microsoft.com/downloads/ (Links to an external
site.)
Install C++ support in Visual Studio: https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-
installation?view=vs-2017 (Links to an external site.)

for Python: PyCharm: https://www.jetbrains.com/pycharm/download/#section=windows (Links to an
external site.)

If you use Linux Ubuntu Systemor Mac OS X:
for C/C++: The gcc/g++ compiler is usually installed by default.

for Python:
PyCharm: (Mac OS) https://www.jetbrains.com/pycharm/download/#section=mac (Links to an
external site.)
PyCharm: (Linux) https://www.jetbrains.com/pycharm/download/#section=linux (Links to an
external site.)

Remark: it is suggested that computers involved in the same working group should use the same
operating system and apply the same software tool for the project design.

3.Project Demo

Apart from the server program, we have also provided the following demo programs to demonstrate the
application’s operations:

For Windows System, the demo program is provided as: Demo program
For Linux System, the demo program is provided as: Demo program

http://compnetworking.about.com/od/wireless/ht/setupadhocwifi.htm
http://www.home-network-help.com/crossover.html
https://canvas.cityu.edu.hk/courses/42813/files/8244161?wrap=1
https://canvas.cityu.edu.hk/courses/42813/files/8244161/download?download_frd=1
https://canvas.cityu.edu.hk/courses/36744/files/6529894/download?wrap=1
https://canvas.cityu.edu.hk/courses/42813/files/8239079/download
https://canvas.cityu.edu.hk/courses/42813/files/8239220/download

2021/11/3 上午10:23 Programming Assignment

https://canvas.cityu.edu.hk/courses/42813/assignments/177986 5/8

For Mac OS, the demo program is provided as: Demo program(for M1 CPU) Demo program(for
Intel CPU)

4. List of Tasks

Task 1: Socket initialization

Description: initialize and create the TCP socket.

Task 2: Initiate the connection request

Description:

Input the file server IP and port.
Initiate a connection on a socket.

Task 3: Send request to the file server, and receive content from the file server and save the file

Description: send the command to the server.

UPLOAD: send the to-be-uploaded file name to the file server. If the file is not in the server, the
program then uploads the file line by line until the last line that consists only of a “#” followed by a
newline character ‘\n’. The file is saved at the server under the file name.
DOWNLOAD: send to-be-downloaded text file name to the server. If the file does not exist, return
FAIL from the server; otherwise, the server will send the file back to the client line by line until it
finishes at the line with ‘#’, and the client saves the file with the same file name locally.
RETRIEVE: send to-be-retrieved text file name to the server. If the file does not exist, return FAIL
from the server; otherwise, the server will return “SUCCESS”.
EXIT: send this command to the server.
UPLOAD/DOWNLOAD/RETRIEVE: if “SUCCESS” is received, it indicates that the server has
successfully received the command with the given file name from clients. Print out “SUCCESS” and
then allow the user to input the next command.
Other cases: receive the error message “ERROR ” that is sent by the server. Print out the error
message and allow the user to input another command.

Task 4: Close socket

Description: when the client has sent the “exit” command and received “SUCCESS” from the server in
response, close the connection socket.

https://canvas.cityu.edu.hk/courses/42813/files/8313171/download
https://canvas.cityu.edu.hk/courses/42813/files/8339156/download

2021/11/3 上午10:23 Programming Assignment

https://canvas.cityu.edu.hk/courses/42813/assignments/177986 6/8

How to find your IP address:

Linux or Mac: Type ifconfig in terminal
Windows: Network & Internet settings -> network properties

5. Project Requirements and Tutorials

5.1. Project Tutorials

To be updated.

5.2. Code Quality

We cannot specify completely the coding style that we would like to see but it includes the following:

Proper decomposition of a program into subroutines (and multiple source code files when necessary)
— A 500 line program as a single routine won’t suffice.
Comment—judiciously, but not profusely. Comments also serve to help a marker, in addition to
yourself. To further elaborate:

Your favorite quote from Star Wars or Douglas Adams’ Hitch-hiker’s Guide to the Galaxy does not
count as comments. In fact, they simply count as anti-comments and will result in reduction of
marks.
Comment your code in English. It is the language of instruction of the university.

Proper variable names — leiais not a good variable name, it never was and never will be.
Use a small number of global variables, if any. Most programs need a very small number of global
variables if any. (If you have a global variable named temp, think again.)
The return values from all function calls should be checked and all values should be dealt with
appropriately.

6. Assessment Tool

You must make it clear how to compile and run your code by explaining it in your readme text
file. The development environment should also be indicated in this file.
TAs are not supposed to fix bugs, neither in your source code nor in your Makefile.
If an executable file cannot be generated or executed successfully, it will be considered as
unsuccessful.
Any program that does not print the output in the format required in Section 1, will be considered as
unsuccessful.

2021/11/3 上午10:23 Programming Assignment

https://canvas.cityu.edu.hk/courses/42813/assignments/177986 7/8

If the program can be run successfully and the output is in the correct form, your program will be
graded according to the following marking scheme in Table 1.

Table 1: Marking scheme.

Components Weight

Initialize socket 10%

Connect to server 10%

UPLOAD command 20%

DOWNLOAD command 20%

RETRIEVE command 10%

Other commands (exit, close connection, etc) 10%

Error handling 10%

programming style and in-program comments 10%

7. Submission

This assignment is to be done individually or by a group of two students. You are encouraged to
discuss the high-level design of your solution with your classmates but you must implement the
program on your own. Academic dishonesty such as copying another student’s work or allowing
another student to copy your work, is regarded as a serious academic offence.
Each submission consists of two files: a source program file (e.g. .cpp, .c, or .py file), a readme (.txt)
file telling us how to compile your code, and a Makefile if applicable.
Use your student ID to name your submitted files, such as 5xxxxxxx-5xxxxxxx.cpp, 5xxxxxxx-
5xxxxxxx-readme.txt, 5xxxxxxx.txt for submission.
Submit the files to Canvas.
No late submission will be accepted.

2021/11/3 上午10:23 Programming Assignment

https://canvas.cityu.edu.hk/courses/42813/assignments/177986 8/8

8. Getting Help

If you have any programming issues, please feel free to contact the following TA: Mr WEN Zihao

zihaowen2- .edu.hk

All contents on this page including source code and documents can only be used for course CS3201.
October, 2021