netflex Protocol Specification v1
V1 spec document for a demo protocol I did for a tutorial.
Quality Status: Release
Implementation Tutorial - Implementing a Network Protocol in C from Start to Finish!
Design Tutorial - How to Design a Network Messaging Protocol!
Netflex has a 3 byte header with an action, option and size. The action determines the instruction the other partner is giving, the option is how they want it done and the size is the size of the payload. The number of payloads varies depending on the type, and before each payload comes the size.
MIN SIZE: 3 bytes
MAX SIZE: 255 bytes
Actions
Action |
Description |
Byte |
Payloads |
WATCH |
Instruct partner to modify the watch list. |
0x00 |
1 |
QUIT |
Instructs partner the sender is exiting. |
0x01 |
0 |
NOTIFY |
Notify the user since an event just occurred. |
0x02 |
2 |
REPLY |
Acknowledge the previous message, or say it was invalid. |
0x03 |
0 |
STATUS |
Let partner know about application-level status conditions. |
0x04 |
0 |
UNSET |
Permanently reserved as the 'null' value for an action. |
0xFF |
0 |
Options
WATCH
Option |
Description |
Byte |
ADD |
Add a file to the watch list. |
0x00 |
REM |
Remove a file to the watch list. |
0x01 |
QUIT
Option |
Description |
Byte |
USER |
User requested to exit the program. |
0x00 |
ERROR |
The partner encountered an error and it will quit. |
0x01 |
NOTIFY
Option |
Description |
Byte |
CREATE |
A file creation event occurred. |
0x00 |
DELETE |
A file deletion event occurred. |
0x01 |
ACCESS |
A file access event occurred. |
0x02 |
CLOSE |
A file close event occurred. |
0x03 |
MODIFY |
A file modification event occurred. |
0x04 |
MOVE |
A file move event occurred. |
0x05 |
REPLY
Option |
Description |
Byte |
VALID |
Acknowledge a valid message. |
0x00 |
BAD_SIZE |
Message exceeded max size or was reported incorrectly. |
0x01 |
BAD_ACTION |
Requested action not known. |
0x02 |
BAD_OPTION |
Requested option not known. |
0x03 |
BAD_PATH |
The path requested to watch could not be found. |
0x04 |
INVALID_DATA |
Data outside ASCII alpha-numeric (plus special characters) range. |
0x05 |
STATUS
Option |
Description |
Byte |
SUCCESS |
Application-level operation success. |
0x00 |
ERR_INIT_INOTIFY |
The partner couldn't initialise an inotify instance. |
0x01 |
ERR_ADD_WATCH |
The partner couldn't add a path to inotify. |
0x02 |
ERR_READ_INOTIFY |
The partner couldn't read from the inotify instance. |
0x03 |
ERR_RM_WATCH |
The partner couldn't remove a path from inotify. |
0x04 |
Examples