0.0
No release in over 3 years
Pure Ruby implementation of the Scalability Protocols wire format used by nanomsg and nng. Includes the SP/TCP framing codec, 8-byte greeting, protocol identifiers, and connection management. No runtime dependencies.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

protocol-sp

CI Gem Version License: ISC Ruby

Pure Ruby codec and connection for the Scalability Protocols (SP) wire format used by nanomsg and nng. Zero runtime dependencies. Sister gem to protocol-zmtp.

What's in the box

  • Protocol::SP::Codec::Frame — length-prefixed framing. SP/TCP uses an 8-byte big-endian length; SP/IPC prepends a 1-byte message type (0x00 control, 0x01 user) to match nng's wire format.
  • Protocol::SP::Codec::Greeting — 8-byte handshake: 00 'S' 'P' 00 <peer-proto:u16-BE> 00 00.
  • Protocol::SP::Protocols — protocol identifier constants (PUSH=0x50, PULL=0x51, PUB=0x20, SUB=0x21, REQ=0x30, REP=0x31, PAIR_V0=0x10, PAIR_V1=0x11, BUS=0x70, SURVEYOR=0x62, RESPONDENT=0x63).
  • Protocol::SP::Connection — mutex-protected #handshake!, #send_message, #write_message (no flush), #write_messages (batched under a single mutex acquisition), #receive_message over any IO-like object. framing: selects :tcp or :ipc.

Notes

  • SP messages are single-frame (no multipart, unlike ZMTP).
  • No security mechanisms in the SP wire protocol — encryption is layered via TLS/WebSocket transports, not the SP framing.
  • No commands at the wire level — protocol-specific control bytes (e.g. REQ request IDs, SUB topics) live inside the message body.
  • Zero-alloc frame headers on the unencrypted hot send path via Array#pack(buffer:).

Usage

protocol-sp is a low-level codec. For a full socket API (PUSH/PULL, REQ/REP, PAIR, transports, reconnect), see nnq.