Last active
December 8, 2019 22:12
-
-
Save Rio6/21fe0a23b93084cf88cd0a095d3782c2 to your computer and use it in GitHub Desktop.
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
#!/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