You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ztellman edited this page May 23, 2011
·
4 revisions
A netstring is a simple, human-readable protocol for sending sequences of strings. The format is just the length of the string, followed by the string itself:
<byte length>:<string>,
["Hello" "World"] would encode to:
5:Hello,5:World,
Note that the length specified does not include the comma. This somewhat complicates the frame, but the definition is still straightforward:
The prefix describes the byte-length, so we use (finite-frame ...) to describe the entire frame. The prefix is a string-integer, with the slight twist that the number is off-by-one from the actual byte-length that follows. To decode the length we must increment the value, and to get the value to encode we must decrement the length. The inner frame is just a string, terminated by a comma.