Netsocket

Introduction

This light weight network protocol is heavily insptired by the ZeroMQ Message Transport Protocol.

Specification

​greeting: "NMP/0.9" identifier
identifier:  short-msg
short-msg: %0x00 OCTET body // OCTET is length of body
body: OCTET*
long-msg:  %0x02 OCTET{4} body //OCTET{4} is length of body represented as UINT32BE
 
SHORT MESSAGE:
+-----------+------------+-------------+ ... +--------------+
| OCTET #1  |  OCTET #2  |  OCTET #3   |     | OCTET #(3+N) |
|------------------------+-------------+     +--------------+
| BITS 0-7  | BITS 0-7   | BITS 0-7    |     |  BITS 0-7    |
|-----------+------------+-------------+     +--------------+
| MSG_FLAGS | MSG_LENGTH | MSG Byte #1 |     |  MSG Byte #N |
|   0x00    |   0-255    |    0-255    |     |     0-255    |
|-----------+------------+-------------+     +--------------+
 
 
LONG MESSAGE:
+-----------+----------+----------+----------+----------+-------------+ ...
| OCTET #1  | OCTET #2 | OCTET #3 | OCTET #4 | OCTET #5 |  OCTET #6   |
|-------------------------------------------------------+-------------+
| BITS 0-7  |          BITS 0-31 (BIG ENDIAN)           |   BITS 0-7  |
|-----------+-------------------------------------------+-------------+
| MSG_FLAGS |               MSG_LENGTH                  | MSG Byte #1 |
|   0x02    |                0-2^32-1                   |    0-255    |
|-----------+-------------------------------------------+-------------+

ping = command-size %d4 "PING" ping-ttl ping-context
ping-ttl = 2OCTET
ping-context = *OCTET
pong = command-size %d4 "PONG" ping-context
ping-context = *OCTET