1.0.1 • Published 5 years ago

net-socket.io v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Net Socket IO

Net-Socket.IO enables real-time, bidirectional and event-based communication for low-level IPC and TCP sockets. It is a small wrapper around node's net library, that makes low-level socket programming easy.

Heavily Based on socket.io and Event Emitters.

For more information on the motivation behind this library, check out my blog post on the subject.

Examples

server

const { Server } = require('net-socket.io');
const socketFile = '/tmp/socket'; // file for IPC socket, or port number for TCP socket.
const io = Server(socketFile);

io.on('connection', function(socket){
  socket.emit('request', /* */); // emit an event to the socket
  io.emit('broadcast', /* */); // emit an event to all connected sockets
  socket.on('reply', function(data){ /* */ }); // listen to the event
});

client

const { Socket } = require('net-socket.io');
const socketFile = '/tmp/socket';
const socket = Socket(socketFile);

socket.on('ready', () => {
  socket.emit('request', /* */);
  socket.on('reply', (data) => { /* */ }); // listen to the event
});

Look in the examples folder for complete examples.

Documentation

Check out the API documentation for more details.

1.0.1

5 years ago

1.0.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago