Skip to content

Like airswarm, but using tcp ports and unix sockets - node.js style

License

Notifications You must be signed in to change notification settings

mcollina/localswarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

localswarm

build status

Network swarm that automagically discovers other peers on the same host using a unix socket and tcp ports. It offers the same API of airswarm.

npm install localswarm --save

Usage

var localswarm = require('localswarm')

localswarm('testing', function (sock) {
  sock.write('hello world (' + process.pid + ')\n')
  sock.pipe(process.stdout)
})

If you run the above program in a couple of processes on the same local network the swarms should start connecting to each other and write hello world

API

swarm = localswarm(name, [options], [onpeer])

Create a new swarm. The swarm will emit peer everytime a new peer is connected. Optionally you can pass a peer listener as the second argument.

The peer will be a tcp stream to another swarm.

swarm.peers

An array containing all the currently connected peers

License

MIT

About

Like airswarm, but using tcp ports and unix sockets - node.js style

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published