Untitled
raw download clone
JAVASCRIPT
views 9
,
size 671 b
var net = require('net');
var ip = require('ip');

exports.start = function () {
    var tcp = net.createServer(function (client) {
        client.on('data', function (data) {
            if (data == "reboot") {
                console.log(getDateTime() + ` Reboot command received`);
                process.exit(1);
            }
			
            console.log(getDateTime() + ` TCP Received message: ` + data);
        });
    });
	
    tcp.listen(42333, ip.address(), function () {
        var serverInfo = tcp.address();

        console.log(getDateTime() + ` TCP server listen on address : ` + serverInfo.address + `:` + serverInfo.port);
    });
}
close fullscreen
Login or Register to edit or fork this paste. It's free.