General packet structure
Elements in brackets are optional. The header specifies which of them are enabled or not. The only way to have a packet without everything except of the header is the null header:
Fields and payload
A packet consists of the following unsigned fields. An additional header of one byte is sent in front of each packet which is calculated out of those fields.
|1||Command||Command to send to server|
|1||Session||when the client receives a reply it can identify the matching request by the session|
A set bit will indicate that the corresponding field of the packet is sent and therefore must be read. If the value of a field is 0, than a field shouldn't be sent.
|Bit position||Field exists|
|Payload up to 256 bytes|
|Payload up to 65536 bytes|
|Out-of-band (fill packets without payload)|