Projet_JAVA_P2P_STRI2A/doc/protocol.md
2020-01-21 10:55:20 +01:00

13 lines
811 B
Markdown

# P2P-JAVA-PROJECT version 1 (Protocol for step 1)
All messages begins with `P2P-JAVA-PROJECT VERSION 1.0\n` (this version of the protocol).
## Client messages
- `LIST\n`: ask the server to list files from server root directory
- `DOWNLOAD\n<FILENAME>\n`: ask the server to download file <FILENAME> from server root directory. Only one filename is allowed per request.
## Server responses
- The response to `LIST` request is in the format `LIST\n<FILENAME 1>\n<FILENAME 2>\n[…]<LAST FILENAME>\n\n`
- The response to `DOWNLOAD` request is `LOAD\n<FILESIZE (BYTES)>\n<CONTENT OF FILE>` or `NOT FOUND\n` if the file doesn't exists.
- The server send a `PROTOCOL ERROR\n` message if it doesn't understands what the client sent.
- The server send a `INTERNAL ERROR\n` message if it encounters an internal error.