title: Possibility of writing to a wrong object with callback
body: <p>I'm using a NodeJS Socket.IO server for handling realtime things. There is also an event in Socket.IO for authenticating a user. The code looks as follows:</p>
  
  <pre><code>var io = require('socket.io').listen(8080)
  
  io.on('connection', function(socket) {
  
      socket.on('auth', function(id) {
  
          conn.query('SELECT id FROM u WHERE id = ?', id, function(e, result) {
  
              socket.id = result[0].id
          })
      })
  )}
  </code></pre>
  
  <p>My worries are about this line here:</p>
  
  <pre><code>socket.id = result[0].id
  </code></pre>
  
  <p>This is in a callback. When the DB executed the query.
  So my question is: Is there a possibility that there can be wrong assignment with a lot of of connections at the same time? Seems that this happened already and data got assigned to the wrong socket object. Are there better methods for reliably do things like this?</p>