The communication between FineDB client and server is based on a binary protocol. Requests start with a byte which describes the command and its options. This byte may be followed by other data, depending on the request type.
Responses start also with a byte containing a result code and some useful information. This byte may be followed by other data, depending on the request type and the result of the request processing.
Request byte
1 1 1 1 1 1 1 1 | | | | | | | | | | | | `--------> command [1] | | | | | | | `----------> synchronous [2] | | | | | `------------> serialized data [3] | | | `--------------> compression [4] | `----------------> server to server command [5]
[1]: Request command.
- 0000 ➔ PING (check the connection)
- 0001 ➔ GET (get a data from its key)
- 0010 ➔ DEL (delete a key/value pair)
- 0011 ➔ PUT (add or update a key/value)
- 0100 ➔ SETDB (set database name for subsequent requests)
- 0101 ➔ START (start a transaction)
- 0110 ➔ STOP (stop a transaction)
- 0111 ➔ not defined yet
- 1000 ➔ not defined yet
- 1001 ➔ not defined yet
- 1010 ➔ not defined yet
- 1011 ➔ not defined yet
- 1100 ➔ not defined yet
- 1101 ➔ not defined yet
- 1110 ➔ ADMIN (administration command)
- 1111 ➔ EXTRA (other command expressed in a second request byte)
[2]: Synchronous request.
[3]: Data are serialized (PUT/ADD/UPDATE request only).
[4]: Compression option.
- GET command ➔ the client accepts compressed data.
- PUT command ➔ compressed data are sent.
[5]: Replication between servers.
Response byte
/------------> unused bit [1] | 1 1 1 1 1 1 1 1 | | | | | | | | | | | | | `--> status bit [2] | | | | | | | | `----------> error code [3] | | | `------------> serialized data [4] | `--------------> compression [5]
[1]: Free for future usage.
[2]: Status of the request processing.
- 0 ➔ error
- 1 ➔ OK
[3]: Type of the encountered error.
- 0000 ➔ undefined error
- 0001 ➔ protocol error
- 0010 ➔ server error
- 0011 ➔ full database
- 0100 ➔ too many opened databases
- 0101 ➔ bad name (dbname for SETDB request, key for GET or DEL request)
- 0110 ➔ transaction error
[4]: Returned data are serialized (GET request only).
[5]: Returned data are compressed (GET request only).