Thin wrapper for creating TCP servers.
$ npm install flow-tcp-server
To use the module,
var createServer = require( 'flow-tcp-server' );
The module exports a single method for creating TCP servers.
To create a server,
var options = {
'host': '127.0.0.1',
'port': 1337
};
var server = createServer( options, onReady );
function onReady() {
var addr = server.address();
console.log( '...server is listening at %s on port %d...', addr.address, addr.port );
}
The options
argument is not required. The default host
is 127.0.0.1
, and the default port
is one which is assigned by the system.
The callback is invoked once the server is ready to accept TCP socket connections.
To run the example code from the top-level application directory,
$ node ./examples/index.js
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ open reports/coverage/lcov-report/index.html
Copyright © 2014. Athan Reines.