DEV Community

Manas Trivedi
Manas Trivedi

Posted on

Blueis-h 2: Making Sense of the Byte Soup

Been a while since the last post, but who could've known that knowing what an event loop is and finally writing to actually implement it are two different beasts (and one is so much more scary 😭).

Once I was done with it though, the time came to decide upon the protocols I'll be using and I decided to go the simplest route available given how this is my first system.

Framing Protocol

For the framing protocol, going the tried and tested route of using a fixed byte length prefix followed by a variable length string seemed easier to implement and more importantly understand, it also fit well with my choice for my next protocol and my project's needs.

Command Protocol

This is the protcol I used to actually parse the commands once we have enough stuff in the buffer to actually constitute a full request. For this I decided to use a fixed length prefix 'nstr' for the number of strings in the command.

This is followed by another fixed length prefix for the length of the first string followed by the string itself, this goes on for however many strings constitute the command.


This works in theory but feels kind of trivial so I'm unable to decide if this is the route I should go but unless I find something more optimal I'll stick with this.

Another progress I made was to just slap an unordered_map at my server to finally get the KV-Store working. This was less thought of as a final feature and more of my own personal wish to see my project in action so I believe the next step I'll be taking is to construct my own hashtable.

This update took a while because Fate didn't like I was finally being a bit productive and decided to make me sick 😭. Hopefully, the next update is much sooner.

Thanks for the read!

Top comments (0)