1.0.0 • Published 5 years ago

tcp-factory v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

Factory for TCP server/client. This is smart wrapper for net module which can help You to build server/client Node.js applications working with custom protocols based on TCP/IP

npm i -s tcp-factory

Provide an options object to the constructor:

const TCP_FACTORY = require('tcp-factory');

const TCP = new TCP_FACTORY({ 
  port: 8888, 
  host: '127.0.0.1', 
  handlers: {
      onClose: () => {
      },
      onData: function (data) {
      },
      onError: (e) => {
      },
      onConnect: function() {
      }
    }
});

TCP.Server - this property is a TCP server which is configured and run with provided options TCP.Client - this property is a tcp client which is configured and with provided options. You should initialize connection with TCP.Client.connect() method running.