Created
June 9, 2010 18:21
-
-
Save pgriess/431915 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
var net = require('net'); | |
var s = new net.Stream(0, 'unix'); | |
s.resume(); | |
s.addListener('fd', function(fd) { | |
http.createServer(function (req, res) { | |
sys.debug("Got request at " + process.pid); | |
res.writeHead(200, {"Content-Type": "text/plain"}); | |
res.end("Hello from " + proces.pid); | |
}).listenFD(fd, "tcp4"); | |
}); |
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
var child_process = require('child_process'); | |
var netBinding = process.binding('net'); | |
for (var i = 0; i < 4; i++) { | |
var fds = netBinding.socketpair(); | |
var cp = child_process.spawn( | |
'node', | |
['worker.js'], | |
undefined, | |
[fds[0], fds[1], -1] | |
); | |
child.stdin.write("http fd", "ascii", fd); | |
child.stderr.addListener('data', function (data) { | |
process.stdout.write(data); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment