CS4445
Project 3 (Due: 11/4/2018)
In this project, you will implement server and client programs for file storage system. The details
are described as follows.
Part 1: Server
When the server gets started, it reads a file (“account.txt”) located in the server computer,
that contains users’ ids, passwords and the names of files that are stored in the server
computer and owned by the corresponding user. Each line in the file contains an account
information; id, password and file names owned by the id are separated by one blank space.
account.txt Example
id1 password1 file1_1 file1_2 file 1_3
id2 password2 file2_1
id3 password3 file3_1 file3_2 file3_3 file3_4 file3_5
id4 password4 file4_1 file4_2 file4_3
…..
After reading “account.txt” file, the server displays the contents of file and waits for TCP
connection request from the client by opening server socket. At this time, server runs a thread
for TCP connection from clients. This means that, a new thread will be created and waiting
for the next new TCP connection when one connection is made multithreaded server. The
server can take up to 5 concurrent connections.
When the server receives a connection request from any client, it checks how many
concurrent connections are open at this moment. If it is larger than 5, the server sends an
error message (e.g. “maximum connections being made and can’t take any additional
connection at this time. Please try again!!!”) to the client and doesn’t accept the new
connection. If not, it accepts the new connection and proceeds to the following steps.
Part 1.1 Log-in Phase
When the number concurrent connections are less than 5, the server sends a message
including 3 options: 1. New User, 2. Existing User, 3. Disconnect.
When the server receives an option #1, the server sends a client a query message to send
new id and new password. The server keeps doing this until it received unique id from
the client. The format of this message is “id*password”; we are using ‘*’ as a delimiter
between id and password.
When the server receives an option #2, the server sends a query message for user’s id and
password and checks if the id and password match in the server. Depending on this
validity check, the server sends a proper message to the client. The server repeats this
until the client enters the correct id and password pair. If entered id and password don’t
match to the ones in the “account.txt” file, after 3 tries, terminate the connection with
proper error message.
When the client chooses an option #3, the connection is terminated.
Part 1.2 File Access Phase
When the client either successfully creates an account or logs in the system, the server
sends the list of files owned by the client. Along with the list of files, the server sends 4
options; 1. Download, 2. Upload, 3. File List, 4. Disconnect.
If the server receives an option #1, the server asks the name of file that the client wants to
download. Once the client sends file name including an extension (e.g. .doc, .jpg…),
server check if it has the file. If so, the server sends the file to client. If not, send an error
message saying that the file doesn’t exist. We are limiting the file format to text files
(.txt) with contents in ascii.
If the server receives an option #2, the server asks to send file so that it can store the file
and update the “account.txt” file. The format of the uploaded file will be
“filename*contents of file…..”; we are using ‘*’ as a delimiter between file name and its
contents. If the server receives a file name which is already in the server, it generates a
new files name which implies that duplicated file name has been received. For example,
assume that there already exists a file name “filename.txt” in the server and the client
transfers “filename.txt” to the server. Then the server changes the file name to
“filename_copy_1.txt” and stores the contents. If the client transfers “filename.txt” one
more time, the server changes its name to “filename_copy_2.txt” and stores the contents.
If the server receives an option #3, it sends the list of files owned by associated user.
When the server receives an option #4, the connection is terminated.
Part 2: Client
The client will connect to the server using TCP connection. When the client gets started, it
asks server’s ip address and port number. Then the user will enter the information for
connection.
Part 2.1 Log-in Phase
When the client is connected to the server, it will receive a message from the server with
3 options: 1. New User 2. Existing User 3. Disconnect.
If the client chooses an option #1, the client receives the query for new id and password
from the server, the client program obtains new id and password from the user. At this
time, the client must validate the id and password; id can include only alphanumeric
characters and password can include alphanumeric characters and the special characters,
‘!’, ‘#’, ‘$’, ‘%’. If user enters invalid characters, client program must keep asking valid
id and password. Once they are validated, the new id and password are sent to the server
in the following format; “id*password” (we are using ‘*’ as a delimiter between id and
password).
If the client chooses an option #2, client is asked to enter the user’s id and password. The
client has maximum of 3 tries to send correct id and password until the access is denied.
If the client chooses an option #3, the connection is terminated.
Part 2.2 File Access Phase
After a client logs in the server, it receives the list of files that the user owns along with 4
options; 1. Download, 2. Upload, 3. File List, 4. Disconnect.
When the client chooses an option #1, it is asked to enter the name of the file (including
its extension) that it wants to download. If the file exists in the server, the file will be
transferred from the server.
When the client chooses an option #2, it is asked to enter the name of the file that it wants
to upload to the server. At this time, the client program must send the file and its’
contents in the following format; “filename*contents of file…..”; we are using ‘*’ as a
delimiter between file name and its contents. Even if the server has the same file name, it
will accept it by changing the file name properly. We are limiting the file format to text
files (.txt) with contents in ascii.
When the client chooses an option #3, it will receive the list of files from the server.
When the client chooses an option #4, the connection is terminated.
Submissions
You must submit the program that compiles and runs without any error to receive full
points.
The programs must terminate gracefully without any exceptions/crashes/errors.
Along with the source code, please include the comments describing about how and
where to run your program; the IDE used, hardware/software environment (e.g. MacBook
with i5, Windows OS, etc…), special instruction to run the code, etc.
Don’t forget to put comments in your source code so that the reader can understand your
program easily.
On the top of each source code file, please don’t forget to put your Name.
You will submit the project to Canvas.
Purchase answer to see full
attachment