title: Socket.IO throwing Type Error
body: <p>I have a simple NodeJS server that uses bcrypt, mysql and socket.IO, that works as a gateway for a mysql database and a chat server. This server connects to the client using Socket.IO client, and sends requests to the server using Socket.IO events. However, the registration event throws a <code>Type Error : undefined is not a function</code>. I have checked all the functions and they exist, so i don't know what is happening. Here is my code to handle the registration event : </p>
  
  <pre><code>socket.on('registration request', function(msg,err) {
          var split = msg.toString().split(":§:");
          var userName = split[0];
          var password = split[1];
          var email = split[2];
  
          console.log("Registration request : " + userName + " &lt;===&gt; " + email); //&lt;====== Prints this to the console then crashes and returns the message below
          if(err){
              console.log("Socket Error !!\n" + err);
          }
          if (pattern.test(userName) &amp;&amp; emailRegex.test(email)) {
              console.log("Data is valid. Coding password");
              password = bcrypt.hashSync(password.toString(), 2);
              console.log("Querying DB");
              DBConnection.query(
                      "INSERT INTO users (user_name,user_password,user_email) VALUES (\""
                              + userName + "\" , \"" + password + "\" , \""
                              + email + "\");", function(error, rows) {
                          if (error) {
                              console.log("Something went wrong in registering " + userName);
                              sIO.sockets.socket(socket.id).emit('registration response', "&lt;ERROR&gt;");
                          } else if (rows.length &gt; 1) {
                              console.log("Registration of " + userName + " succeded");
                              sIO.sockets.socket(socket.id).emit('registration response', "&lt;SUCCESS&gt;");
                          } else {
                              console.log("Registration of " + userName + "denied")
                              sIO.sockets.socket(socket.id).emit('registration response', "&lt;DENIED&gt;");
                          }
                      });
          } else {
              socket.emit('registration response', "&lt;DENIED&gt;");
          }
      });
  </code></pre>
  
  <p>And here is the error message : </p>
  
  <pre><code>Missing error handler on `socket`.
  TypeError: undefined is not a function
      at Socket.&lt;anonymous&gt; (/root/ChatServer/index.js:109:15)
      at Socket.emit (events.js:107:17)
      at Socket.onevent (/root/ChatServer/node_modules/socket.io/lib/socket.js:330:8)
      at Socket.onpacket (/root/ChatServer/node_modules/socket.io/lib/socket.js:290:12)
      at Client.ondecoded (/root/ChatServer/node_modules/socket.io/lib/client.js:193:14)
      at Decoder.Emitter.emit (/root/ChatServer/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
      at Decoder.add (/root/ChatServer/node_modules/socket.io/node_modules/socket.io-parser/index.js:247:12)
      at Client.ondata (/root/ChatServer/node_modules/socket.io/lib/client.js:175:18)
      at Socket.emit (events.js:107:17)
      at Socket.onPacket (/root/ChatServer/node_modules/socket.io/node_modules/engine.io/lib/socket.js:99:14)
  </code></pre>
  
  <p>I can't find my error. Your help would be greatly apreciated.</p>