title: Socket.io emit and .on not working
body: <p>I am learning <code>Node js</code> with <code>socket</code>. I got a sample program from <a href="https://codeforgeek.com/2015/09/real-time-notification-system-using-socket-io/#comment-27230" rel="nofollow">Here</a></p>
  
  <p>When I try to run it, it is not showing the error, but also nothing happening. </p>
  
  <p>I tried and find out that the <code>socket.emit</code> and <code>socket.io</code> are not triggering.</p>
  
  <p><strong>Client side</strong></p>
  
  <pre><code>$("#addComment").click(function(event){
              var userName = $("#name").val();
              var userComment = $("#comment").text();
              if(userName === "" || userComment === "") {
                  alert("Please fill the form.");
                  return;
              }
              socket.emit('comment_added',{user : userName, comment : userComment});
              socket.on('notify_everyone',function(msg){
                  notifyMe(msg.user,msg.comment);
              });
          });
  
  function notifyMe(user,message) {
          // Let's check if the browser supports notifications
          if (!("Notification" in window)) {
              alert("This browser does not support desktop notification");
          }
          // Let's check if the user is okay to get some notification
          else if (Notification.permission === "granted") {
              // If it's okay let's create a notification
              var options = {
                  body: user + "Posted a comment" + message,
                  dir : "ltr"
              };
              var notification = new Notification("Hi there",options);
          }
          // Otherwise, we need to ask the user for permission
          // Note, Chrome does not implement the permission static property
          // So we have to check for NOT 'denied' instead of 'default'
          else if (Notification.permission !== 'denied') {
              Notification.requestPermission(function (permission) {
                  // Whatever the user answers, we make sure we store the information
                  if (!('permission' in Notification)) {
                      Notification.permission = permission;
                  }
                  // If the user is okay, let's create a notification
                  if (permission === "granted") {
                      var options = {
                          body: user + "Posted a comment" + message,
                          dir : "ltr"
                      };
                      var notification = new Notification("New comment added.",options);
                  }
              });
          }
          // At last, if the user already denied any notification, and you
          // want to be respectful there is no need to bother them any more.
      }
  </code></pre>
  
  <p><strong>Server side</strong></p>
  
  <pre><code>io.on('connection',function(socket){
  console.log('We have user connected !');
  io.sockets.on('comment_added',function(data){
      console.log(data);
      db.addComment(data.user,data.comment,mysql,pool,function(error,result){
          if (error) {
              io.emit('error');
          } else {
              socket.broadcast.emit("notify_everyone",{user : data.user,comment : data.comment});
          }
      });
  });
  });
  </code></pre>