The first line is called the meta frame. The `<VALUES>` and their corresponding meanings are as follows:
The first line is called the meta frame. The `<VALUES>` and their corresponding meanings are as follows:
- **`VERSION`**: The version of the protocol, in semver form, i.e `major.minor.patch`.
* **`VERSION`**: The version of the protocol, in semver form, i.e `major.minor.patch` .
An example can be: `0.1.0`
An example can be: `0.1.0`
- **`QTYPE`**: This is the type of query. It can have the following values:
* **`QTYPE`**: This is the type of query. It can have the following values:
- `GET` : For `GET` operations
- `GET` : For `GET` operations
- `SET` : For `SET` operations
- `SET` : For `SET` operations
- `UPDATE` : For `UDPATE` operations
- `UPDATE` : For `UDPATE` operations
- `DEL` : For `DEL` operations
- `DEL` : For `DEL` operations
- **`LENGTH`**: The number of bytes that are being transmitted. This is useful for preallocating buffers for copying the data.
#### Example meta frame
#### Example meta frame
```
```
TP 0.1.0/Q GET/15
TP/0.1.0/Q/GET
```
```
### Line 2: Line break
### Line 2 and subsequent lines: Data frame
This is a line break that separates the meta frame from the data frame.
### Line 3: Data frame
The data frame doesn't have any defined format. It can be anything that can be transferred over TCP - that is, well, anything: letters, numbers or vaguely bytes.
The data frame doesn't have any defined format. It can be anything that can be transferred over TCP - that is, well, anything: letters, numbers or vaguely bytes.
## The `R` esult packet
## The `R` esult packet
The `R` esult packet has the following structure:
The `R` esult packet has the following structure:
```
```
TP <VERSION>/R <QTYPE>/<RESPONSECODE>/<LENGTH>
TP/<VERSION>/R/<RESPONSECODE>/<LENGTH>
\n
--------------------- DATA -------------------
--------------------- DATA -------------------
```
```
**Note:** The first line is followed by a line break, and then the subsequent lines.
**Note:** The first line is followed by a line break, and then the subsequent lines.
### Line 1: Meta frame
### Line 1: Meta frame
Just like the `Q` uery packet, the first line is called the meta frame.
Just like the `Q` uery packet, the first line is called the meta frame.
The `<VALUES>` and their corresponding meanings are as follows:
The `<VALUES>` and their corresponding meanings are as follows:
- **`VERSION`**: The version of the protocol, in semver form, i.e `major.minor.patch`.
* **`VERSION`**: The version of the protocol, in semver form, i.e `major.minor.patch` .
An example can be: `0.1.0`
An example can be: `0.1.0`
- **`QTYPE`**: This is the type of query. It can have the following values:
- `GET`: For responses to `GET` operations
* **`RESPONSECODE`**: This is the outcome of the query. It can have the following values:
- `SET`: For responses to `SET` operations
- `UPDATE`: For responses to `UPDATE` operations
- `DEL`: For response to `DEL` operations
This must match with the initial query packet.
- **`RESPONSECODE`**: This is the outcome of the query. It can have the following values:
- 0: Okay
- 0: Okay
- 1: Not found
- 1: Not found
- 2: Method not allowed
- 2: Method not allowed
- 3: Server error
- 3: Server error
- 4: Corrupt byte
- 4: Corrupt byte
- 5: Protocol version mismatch
- 5: Protocol version mismatch
-**`LENGTH`**: The number of bytes that are being transmitted. This is useful for preallocating buffers for copying the data.
***`LENGTH`**: The number of bytes that are being transmitted. This is useful for preallocating buffers for copying the data.
#### Example data frame
#### Example data frame
```
```
sayan is writing a protocol
sayan is writing a protocol
```
```
## An example of a query/result
## An example of a query/result
Let us assume a key called `sayan` with a value of '17' exists on the database.
Let us assume a key called `sayan` with a value of '17' exists on the database.
Our client, uses `0.1.0` version of tp and sends a `GET` request for the key to our server which also uses version `0.1.0` of tp.
Our client, uses `0.1.0` version of tp and sends a `GET` request for the key to our server which also uses version `0.1.0` of tp.