#protocols #message #networking #tcp #binary #byte

message_protocol

A protocol for seperating binary messages over TCP, similar to WebSockets but more minimal

2 releases

0.1.1 Aug 24, 2020
0.1.0 Aug 17, 2020

#251 in WebSocket

MIT license

12KB
218 lines

message_protocol

A protocol for seperating binary messages over TCP, similar to WebSockets but more minimal.

Our protocol for message size is similar to WebSockets, but not exactly the same.

If the first byte is 0-253, this is the length of the message content.

If the first byte is 254, read the next 2 bytes, this 16 bit number is the length.

If the first byte is 255, read the next 8 bytes, this 64 bit number is the length.


lib.rs:

Our protocol for message size is similar to WebSockets, but not exactly the same.

If the first byte is 0-253, this is the length of the message content.

If the first byte is 254, read the next 2 bytes, this 16 bit number is the length.

If the first byte is 255, read the next 8 bytes, this 64 bit number is the length.

Encodes a binary message so it can be read on the other side. Decodes a binary message, which was encoded on the other side. May return an error if the data is invalid.

Dependencies

~120KB