Created
July 24, 2015 23:07
-
-
Save AshuJoshi/9699922356744b4ef2fa to your computer and use it in GitHub Desktop.
Revisions
-
AshuJoshi created this gist
Jul 24, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ /* Simple Node.js TCP Socket Server Author: Ashu Joshi */ "use strict'"; const SERVER_PORT = 10000; const net = require('net'), server = net.createServer(function (connection) { console.log('Client Connected'); connection.on('end', function () { console.log('Client Disconnected'); }); connection.on('data', function(data){ console.log('Receiving data from client....'); var response = data.toString().trim(); // Log the data received console.log(response); }); }); // listen on the port, '' implies all interfaces, function called when server binds to the port server.listen(SERVER_PORT, '', function () { console.log('Server Bound'); });