tcpserver
v2.1.1
Published
A simple tcp server
Downloads
5
Readme
TcpServer
A simple tcp server.
Installation
npm install tcpserver --save
Usage
const TcpServer = require('tcpserver');
const tcpServer = new TcpServer(1234);
tcpServer.on('connect', client => {
console.log('%s:%s connect.', client['ip'], client['port']);
});
tcpServer.on('data', client => {
let data = client['data'].toString();
console.log('%s:%s send: %s.', client['ip'], client['port'], data);
tcpServer.broadcast(data);
});
tcpServer.on('close', client => {
console.log('%s:%s close.', client['ip'], client['port']);
});
tcpServer.start();
License
MIT