-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprotocol.txt
More file actions
56 lines (51 loc) · 1.27 KB
/
protocol.txt
File metadata and controls
56 lines (51 loc) · 1.27 KB
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
Protocol
--------
What information are we sending around?
- Client to Server
- Username
- Commands and arguments
- File Metadata
- File chunks
- Exit signal?
- Server to Client
- Username validation (OK/INVALID/TAKEN)
- Invalid command
- Unknown user
- Connected users
- Incoming requests
- File metadata
- File chunks
- OK command failed (NO REQUEST)
- NO command success
1 byte unique code, followed by behaviour unique to the code
What items need unique codes?
- Username
- 1 followed by \0 terminated username
- Username OK
- 2
- Username INVALID
- 3
- Username TAKEN
- 4
- File metadata
- 5 followed by null terminated filename followed by 4 bytes for file size BE
- File chunk
- 6 followed by null terminated filename, 2 bytes for chunk size BE, followed by data
- Connected users
- 7 followed by 2 bytes for number of users BE, followed by null terminated usernames
- Incoming requests
- 8 followed by 2 bytes for number of requests BE, followed by "<from>\0<filename>\0"
- Commands
- 9 followed by 1 byte command code
Command codes:
- list = 1
- reqs = 2
- glide = 3 followed by <path>\0<username>\0
- ok = 4 followed by <username>\0
- no = 4 followed by <username>\0
- OK Command failed
- 10
- NO Command success
- 11
- Client disconnected
- 12