Skip to content

Instantly share code, notes, and snippets.

@jbrjake
Created February 5, 2014 21:40
Show Gist options
  • Save jbrjake/8833728 to your computer and use it in GitHub Desktop.
Save jbrjake/8833728 to your computer and use it in GitHub Desktop.
You have a stream of bytes in char array buf[]:
00 00 00 0A 68 65 6C 6C 6F 77 6F 72 6C 64
You know the bytes follow a protocol with this spec:
<1 byte> message type (0 == hello, 1 == goodbye)
<3 bytes> message length
<N> message content (UTF-8 characters)
Determine if this is a hello message, and, if it is, print the content as a string to stdout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment