Skip to content

Instantly share code, notes, and snippets.

@jots
Created May 2, 2014 07:12
Show Gist options
  • Save jots/11469118 to your computer and use it in GitHub Desktop.
Save jots/11469118 to your computer and use it in GitHub Desktop.
# length of data in 32-bit unsigned, network (big-endian) byte order
# plus the data (and increase length by 4 to account for length field
def packed(xml)
[xml.size + 4].pack("N") + xml
end
puts packed("a test packet")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment