· 7 years ago · Apr 16, 2018, 12:02 AM
1this is the relevant part of the spec
2"Messages from client to server
3
4Numbers in all messages must be in network byte order. All messages from the client to the server have this format:
5
6 Bytes 0-3: A 4-byte unsigned integer containing SecretKey.
7 Bytes 4-5: A 2-byte unsigned integer (a short) containing the type of request: set (0), get (1), digest (2), run (3).
8 Bytes 6-7: Two bytes of padding, with arbitrary values.
9
10The remainder of the bytes are command-specific.
11
12 Set request
13 Bytes 8-23: a null-terminated variable name, no longer than 15 characters.
14 Bytes 24-25: A 2-byte unsigned integer (short) giving the length of the value, which must not exceed 100, including the concluding null (for a string value).
15 Bytes 26 ..: The value itself. The client need not send any more than the number of bytes required.
16 Get request
17 Bytes 8-23: a null-terminated variable name, no longer than 15 characters.
18 Digest request
19 Bytes 8-9: a 2-byte unsigned integer (short) giving the length of the value, which must not exceed 100.
20 Bytes 10 ...: The value itself. The client need not send any more than the number of bytes required.
21 Run request (extra credit)
22 Byte 8-15: an 8-byte string (null terminated) holding one of the valid values.
23
24Messages from server to client
25Numbers in all messages must be in network byte order. If a client sends a request with an invalid secret key, the server should close the connection without returning any message at all.
26
27All messages from the server to the client have this format:
28
29 Byte 0: A 1-byte return code: 0 for success, -1 for failure.
30 Bytes 1-3: Three bytes of padding, with arbitrary values.
31
32The remainder of the bytes are command-specific.
33
34 Set response
35 No further data
36 Get, Digest, and (extra credit) Run response
37 Bytes 4-5: A 2-byte unsigned integer (short) giving the length of the value, which must not exceed 100, including the concluding null (for a string value).
38 Bytes 6 ..: The value itself. The server need not send any more than the number of bytes required.
39"