Last active
June 13, 2018 14:57
-
-
Save Vchekryzhov/15ff340d0c9d2586af4ac16ba126ede2 to your computer and use it in GitHub Desktop.
Connection to node via telnet
This file contains 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 characters
var net = require("net"), | |
repl = require("repl"); | |
connections = 0; | |
repl.start({ | |
prompt: "node via stdin> ", | |
input: process.stdin, | |
output: process.stdout | |
}); | |
net.createServer(function(socket) { | |
connections += 1; | |
repl.start({ | |
prompt: "node via Unix socket> ", | |
input: socket, | |
output: socket | |
}).on('exit', function() { | |
socket.end(); | |
}) | |
}).listen("/tmp/node-repl-sock"); | |
net.createServer(function(socket) { | |
connections += 1; | |
repl.start({ | |
prompt: "node via TCP socket> ", | |
input: socket, | |
output: socket | |
}).on('exit', function() { | |
socket.end(); | |
}); | |
}).listen(5001); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment