Skip to content

Instantly share code, notes, and snippets.

@telamon
Created February 4, 2012 23:13
Show Gist options
  • Save telamon/1741019 to your computer and use it in GitHub Desktop.
Save telamon/1741019 to your computer and use it in GitHub Desktop.
Telnet client in node
var net = require('net');
var client = net.connect(parseInt(process.argv[3]),process.argv[2],function(){
client.setEncoding('utf8');
console.log('Connected!!');
client.on('data',function(chunk){
console.log(chunk);
});
process.stdin.resume(); // Activate STDIN
process.stdin.setEncoding('utf8'); // Set it to string encoding
process.stdin.on('data',function(chunk){ // Pipe STDIN to Socket.out
client.write(chunk);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment