punt
tiny / elegant UDP messaging library
Last updated 12 years ago by tjholowaychuk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install punt 
SYNC missed versions from official npm registry.

Punt

A small layer on top of node's core UDP module to make fast volatile messaging even simpler. Punt uses the tiny AMP prototol to serialize buffer, string, and json arguments.

Installation

$ npm install punt

Example

A small in-proc example of a server with three clients:

var punt = require('punt');
var server = punt.bind('0.0.0.0:5000');
var a = punt.connect('0.0.0.0:5000');
var b = punt.connect('0.0.0.0:5000');
var c = punt.connect('0.0.0.0:5000');

server.on('message', function(msg){
  console.log(msg);
});

setInterval(function(){
  a.send({ hello: 'world' });
}, 150);

setInterval(function(){
  b.send('hello world');
}, 150);

setInterval(function(){
  c.send(new Buffer('hello'));
}, 150);

yielding:

<Buffer 68 65 6c 6c 6f>
hello world
{ hello: 'world' }
<Buffer 68 65 6c 6c 6f>
hello world
{ hello: 'world' }
...

API

Server(addr)

Bind to the given addr.

Client(addr)

Connect to the given addr.

Client#send(...)

Send one or more arguments a single atomic message. The following types are supported through AMP:

  • strings
  • buffers
  • objects (serialized as JSON)

License

MIT

Current Tags

  • 2.3.0                                ...           latest (11 years ago)

6 Versions

  • 2.3.0                                ...           11 years ago
  • 2.2.0                                ...           12 years ago
  • 2.1.0                                ...           12 years ago
  • 2.0.0                                ...           12 years ago
  • 1.0.1                                ...           13 years ago
  • 1.0.0                                ...           13 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 5
Last Month 1
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |