
Node.js is a server-side JavaScript framework used for developing event-driven networking programs for concurrency rather then threading.
var net = require('net');
port = 8001;
net.createServer(function (stream) {
stream.setEncoding('utf8');
stream.on('connect', function () {
stream.write('hi, Your connected to my TCP Server!');
});
stream.on('data', function (data) {
stream.write('Writing network data..');
});
stream.on('end', function () {
stream.write("bye bye");
stream.end();
});
}).listen(port, "localhost");
console.log("Server started at port "+port);
Conclusion
The example above is a basic TCP server that does nothing useful. However, by abstracting this code you can make your new TCP Server do anything you want!


