Thanks for sharing the module.  I use a similar technique for sending
msgpack encoded messages over plain sockets in smith.
https://github.com/c9/smith/blob/master/smith.js#L149-190

On Fri, Jul 20, 2012 at 9:44 PM, LLeo <lle...@gmail.com> wrote:
> I have worked up my first serious npm module. It is a framing protocol for
> straight socket communications.
>
> Rather that separating messages by some identifier (usually a newline), my
> framing protocol writes a simple 32bit unsigned integer in network order
> (big-endian) indicating the length of the message, then message is sent.
> This is simple at first, but it gets complicated quickly.
>
> The constructor is simple `var frap = new Frap(socket)`
>
> Using this module you can send and receive a message either as a single
> Buffer or series of Buffers. Single buffers are sent and received as
> frap.write(buf) and
> frap.on('data', function(buf){...}). A collection of buffers can be sent and
> received as a single message (aka "frame") with frap.sendFrame(buf0, ...,
> bufN) and frap.on('frame', function(bufs){...} . Thats the easy part.
>
> You can also receive frames as a Readable Stream with frap.on('header',
> function(rstream, framelen){...}). And you can send frames as a writable
> stream with `wstream = frap.createWriteStream(framelen)`.
>
> I spent a good amount of effort working on efficientcy in space and time.
> Frap supports a customized pipe() that passes buffers at the frame and
> sub-frame level.
>
> The real utility of this module is for sending large binary blobs between
> node instances. And given how simple the framing protocol is it would be
> relatively easy to implement in any other language.
>
>
> I hope this is useful,
> -LLeo.
>
> PS. this is my first posting and I am using the web interface. I hope the
> formatting doesn't suck.
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to