2011-10-07 11:43:44 +02:00
|
|
|
var assert = require('assert');
|
2011-10-07 22:58:49 +02:00
|
|
|
var net = require('net');
|
|
|
|
|
|
|
|
var connections = 0;
|
2011-10-07 11:43:44 +02:00
|
|
|
|
2011-10-08 01:43:53 +02:00
|
|
|
process.on('message', function(m, serverHandle) {
|
2011-10-07 11:43:44 +02:00
|
|
|
console.log('CHILD got message:', m);
|
|
|
|
assert.ok(m.hello);
|
2011-10-07 22:58:49 +02:00
|
|
|
|
2011-10-08 01:43:53 +02:00
|
|
|
assert.ok(serverHandle);
|
2011-10-07 22:58:49 +02:00
|
|
|
|
2011-10-08 01:43:53 +02:00
|
|
|
var server = new net.Server(function(c) {
|
2011-10-07 22:58:49 +02:00
|
|
|
connections++;
|
|
|
|
console.log('CHILD got connection');
|
|
|
|
c.destroy();
|
|
|
|
process.send({ childConnections: connections });
|
|
|
|
});
|
2011-10-08 01:43:53 +02:00
|
|
|
|
|
|
|
// TODO need better API for this.
|
|
|
|
server._backlog = 9;
|
|
|
|
|
|
|
|
server.listen(serverHandle, function() {
|
|
|
|
process.send({ gotHandle: true });
|
|
|
|
});
|
2011-10-07 11:43:44 +02:00
|
|
|
});
|
|
|
|
|