LearnBoost/socket.io — Issue #747: io.sockets is undefined
Author: bethrobson
Created: 2012-02-13 22:14:23+00:00
State: open

Here's the error message:
mac-pro:~/Sites/Node.js] Beth% !node
node socketserver.js
info - socket.io started

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'on' of undefined
at Object. (/Users/Beth/Sites/Node.js/socketserver.js:6:12)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)

Here's the code:
/* web socket server */

var io = require("socket.io");
io.listen(8124);

io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});