Skip to content

Instantly share code, notes, and snippets.

@Rio6
Last active December 8, 2019 22:12
Show Gist options
  • Save Rio6/21fe0a23b93084cf88cd0a095d3782c2 to your computer and use it in GitHub Desktop.
Save Rio6/21fe0a23b93084cf88cd0a095d3782c2 to your computer and use it in GitHub Desktop.
#!/usr/bin/node
var net = require('net')
var sock = net.connect(process.argv[3] || 5001, process.argv[2])
process.stdin.pipe(sock)
sock.pipe(process.stdout)
sock.on('connect', function () {
process.stdin.resume();
process.stdin.setRawMode(true)
})
sock.on('close', function done () {
process.stdin.setRawMode(false)
process.stdin.pause()
sock.removeListener('close', done)
})
process.stdin.on('end', function () {
sock.destroy()
console.log()
process.exit();
})
process.stdin.on('data', function (b) {
if (b.length === 1 && b[0] === 4) {
process.stdin.emit('end')
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment