var path = require('path');var netBindings = process.binding('net');var Worker = require('webworker').Worker;var fd = netBindings.socket('tcp4');netBindings.bind(fd, 8080);netBindings.listen(fd, 128);for (var i = 0; i < 3; i++) {var w = new Worker(path.join(__dirname, 'worker.js'));w.postMessage({ 'banner' : 'Hello, world!' }, fd);}
var assert = require('assert');var http = require('http');
var banner = undefined;
var srv = http.createServer(function(req, resp) {resp.writeHead(200, {'Content-Type' : 'text/plain'});resp.write(banner + ' (pid ' + process.pid + ')\n');resp.end();});onmessage = function(msg) {assert.ok(msg.fd && msg.fd > 0);banner = msg.data.banner;srv.listenFD(msg.fd);};
% curl 'http://localhost:8080'Hello, world! (pid 27727)% curl 'http://localhost:8080'Hello, world! (pid 27728)% curl 'http://localhost:8080'Hello, world! (pid 27729)% curl 'http://localhost:8080'Hello, world! (pid 27727)
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
This is interesting. How are these web workers related to the ones in
HTML5? Same API?
--
Erik Corry
--