Socket
Socket
Sign inDemoInstall

packet-stream-codec

Package Overview
Dependencies
3
Maintainers
9
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    packet-stream-codec

Binary codec for packet-stream


Version published
Weekly downloads
505
increased by106.12%
Maintainers
9
Install size
32.4 kB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 29 Jan 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc