Binary Protocol
Sending binary request
The request to the API servers starts with 16 bit length of the request, the request itself and optional data. The length obviously limits the request length to 64K and DOES NOT include the length of the data that may be present. The first byte of the request gives the length of the name of the method -
method_len (bits 0-6) and indicates if the request
has data (bit 7). If the highest bit(7) is set, than the following 8 bytes represent 64 bit number, that is the length of the data that comes immediately after the request. The next
method_len bytes are the name of the method to be called. The following one byte represent 8 bit number containing the number of parameters passed. All numbers are
positive numbers. If you need to send a negative number (for example a negative file descriptor, see below), send it as string. There are 3 types of parameters passed to API servers (with their code):
Code | Description |
0 | string |
1 | 64bit number |
2 | boolean |
For each parameter, the first byte represent the parameter type index in two highest bits (6-7) and the length of the parameter name ( param_name_len ) in the low 6 bits (0-5). The following param_name_len bytes are the name of the parameter. If the parameter is :
Code | Description |
string | 4 byte length and string contents follow |
number | 8 byte (64 bit) number representation follow |
boolean | 1 byte, zero representing false and all other values represent true |