开发者社区> 镜像站> NPM> packet-stream-codec
packet-stream-codec
binary codec for packet-stream
Last updated 3 years ago by dominictarr .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install packet-stream-codec 
SYNC missed versions from official npm registry.

packet-stream-buffers

A tight binary codec for packet-streams (the internal component to muxrpc)

This allows streams of binary data, and also supports json objects. (although, you can't send a buffer inside a json object, but so far we have not done this in secure-scuttlebutt, so performance is more important)

The protocol sends zero or more header:body pairs, then a final header that is all zeros.

(
  [flags (1byte), length (4 bytes, UInt32BE), req (4 bytes, Int32BE)]
  [body (length bytes)]
) *
[zeros (9 bytes)]

flags indicates the encoding type of the body, and whether it's part of a stream, or an error/end value.

flags is just one byte.

[ignored (4 bits), stream (1 bit), end/err (1 bit), type (2 bits)]
type = {0 => Buffer, 1 => String, 2 => JSON}

License

MIT

Current Tags

  • 1.1.2                                ...           latest (3 years ago)

4 Versions

  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (3)