anternet

A framework of libraries based on UDP protocol for peer-to-peer communications.

Usage no npm install needed!

<script type="module">
  import anternet from 'https://cdn.skypack.dev/anternet';
</script>

README

anternet.js

build npm Join the chat at https://gitter.im/Anternet/anternet.js npm

Anternet is a framework of libraries based on UDP protocol for peer-to-peer communications.

Libraries

More libraries is on the way..

Example

const Anternet = require('anternet');

const msgType = 1; // can be any positive number
const address = '127.0.0.1';
const port = 12345;

  
// peer 1
const anternet1 = new Anternet();
anternet1.bind(port);

anternet1.on(msgType, (rid, args, rinfo) => {
  anternet1.response(rid, args.reverse(), rinfo.port, rinfo.address);
});

// peer 2
const anternet2 = new Anternet();
anternet2.request(msgType, ['foo', 'bar'], port, address, (err, args, rinfo) => {
  console.log(args); // [ "bar", "foo" ]
});

License

MIT License. Copyright © 2016 Moshe Simantov