Skip to content

Instantly share code, notes, and snippets.

@adammw
Created October 17, 2011 12:45
Show Gist options
  • Select an option

  • Save adammw/1292530 to your computer and use it in GitHub Desktop.

Select an option

Save adammw/1292530 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var net = require('net'),
spawn = require('child_process').spawn;
var server = net.createServer(function(socket) {
socket.write("Connected to <insert program here> Server\r\n");
var proc = spawn("<insert program here>");
socket.pipe(proc.stdin);
proc.stdout.pipe(socket);
proc.on('end', function() {
socket.end();
});
socket.on('end', function() {
proc.kill();
});
});
server.listen(1337);
console.log('Listening on port 1337');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment