Skip to content

Instantly share code, notes, and snippets.

@Vchekryzhov
Last active June 13, 2018 14:57
Show Gist options
  • Save Vchekryzhov/15ff340d0c9d2586af4ac16ba126ede2 to your computer and use it in GitHub Desktop.
Save Vchekryzhov/15ff340d0c9d2586af4ac16ba126ede2 to your computer and use it in GitHub Desktop.
Connection to node via telnet
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