This repository has been archived by the owner on May 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
spec.txt
64 lines (58 loc) · 3.43 KB
/
spec.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
HomeWork III Non-Blocking File Transfer
In this homework, you have to practice Nonblocking IO in a network program.
You should write a server and a client, the server has to be a single process & single thread non-blocking server, and all connections are TCP in this homework.
[I].The concept of this homework is like dropbox.
First, an user can save his files on the server.
Second, the clients of the user are running on different hosts.
Third, when any of client of the user upload a file, the server have to transmit it to all the other clients of the user.
Forth, when a new client of the user connects to the server, the server should transmit all the files, which are uploaded by the other clients of the user, to the new client immediately.
Fifth, we will type /put fileXXX on different clients at the same time, your programs have to deal with this case.
Sixth, if one of the client is sleeping, server has to send the data to the other clients of the user in a non-blocking way.
Seventh, the uploading data only need to send to the clients which are belong to the user.
Note: In your server program, you should include these two lines to achieve the non-blocking function.
"int flag=fcntl(sock,F_GETFL,0);"
"fcnctl(sock,F_SETTFL,flag|O_NONBLOCK);"
Please confirm that your server is non-blocking, we will test the correctness of your server when the server's sending buffer is full.
[II].Inputs
1. ./client <ip> <port> <username>
Please make sure that the you should excute the client program in this format.
2. ./server <port>
Please make sure that the you should excute the server program in this format.
3. /put <filename>
This command, which is used on client side by users, is to upload your files to the server side.
Users can transmit any files they want, but it has to be put in the same directory of client.
The filename should send to the other clients.
4. /sleep <seconds>
This command is to let client to sleep.
5. /exit
This command is to disconnect with server and terminate the program.
[III].Outputs
1. Welcome message.
"Welcome to the dropbox-like server! : <username>"
2. Uploading progess bar.
Downloading file : <filename>
Progress : [############ ]
Download <filename> complete!
3. Downloading progess bar.
Uploading file : <filename>
Progress : [######################]
Upload <filename> complete!
5. Sleeping count down.
/sleep 20
Client starts to sleep
Sleep 1
.
.
Sleep 19
Sleep 20
Client wakes up
[IV].Testing
1.We will run 4 clients on different hosts.
2.Then, we will type "/sleep 20" to let one client sleep for 20s.
3.Within this 20s, we will let 1 client transmit a file to server, server will transmit it to all the other clients of the user, including "sleep" one.
4.Your server should send to other clients normally even if one of the client sleeps.
5.We will check your server has to be non-blocked, which means your client can receive file content normally even if one of the client is sleeping.
Besides, we also test all other functions we mentioned in this spec, and we will use "diff" to compare the files whether they are the same to ensure file transfer complete.
Extremely prohibit from using fork, you can just have single process of your server.
[V].Hint
You can use different connections to transmit files and command separately.