title: node.js and socket.io - broadcast is undefined
body: <p>Using Node.js and socket.io, the following works fine unti trying to broadcast back to the clients.</p>
  
  <p>I am getting broadcast undefined? </p>
  
  <pre><code>var http = require('http'),
      sys  = require('sys'),
      fs   = require('fs'),
      io   = require('socket.io');
  
  var server = http.createServer(function(request, response) {
    response.writeHead(200, {
      'Content-Type': 'text/html'
    });
  
    var rs = fs.createReadStream(__dirname + '/index.html');
    sys.pump(rs, response);
  
  });
  
  var socket = io.listen(server);
  debugger;
  socket.on('connection', function(client) {
    debugger;
    var username;
  
    client.send('Welcome to this socket.io chat server!');
    client.send('Please input your username: ');
  
    client.on('message', function(message) {
      if (!username) {
        username = message;
        client.emit('Welcome, ' + username + '!');
        return;
      }
      socket.broadcast.send('a message');
      //io.socket.send('a message');
      //io.socket.emit('message', username + ' sent: ' + message);
    });
  
  });
  
  server.listen(4000);
  </code></pre>