title: Socket.IO -- ReferenceError: io is not defined, used to work on another website
body: <p>I have always used the code below to do this, in another website it worked fine, but now it's not.</p>
  
  <p><strong>server.js</strong></p>
  
  <pre><code>var io = require('socket.io').listen(8080);
  
  var users = {};
  console.log("Sever is now running");
  
  io.sockets.on('connection', function (socket) { 
      console.log("connection");
      socket.emit('connected');
  
  });
  </code></pre>
  
  <p>The server seems to be fine, I think. It shows the console.log message anyways. Though the second console.log doesn't show up, but I just figured it was because of the error or whatever. </p>
  
  <p><strong>data.js</strong></p>
  
  <pre><code>var socket = io.connect(window.location.origin, {port:8080});
  
  $(document).ready(function(){
      socket.on('connected', function () {    
          alert("A");
      });
  });
  </code></pre>