title: How to get unique client ID in socket.io?
body: <p>In my code 'main.js' I am trying to print socket ID of client. When I connect a client to my server 'main.js', The code does not print anything, either in the console or the browser.</p>
  
  <p>Server side code(main.js): </p>
  
  <pre><code>var app = require('express')();
  var server = require('http').Server(app);
  var io = require('socket.io')(server);
  var port = 8000;
  server.listen(port)
  
  app.get('/',function(req,res){
      res.send({name:ID});
  });
  
  var ID;
  io.on('connection',function(socket){
          ID = socket.id;
          console.log('client id - '+ID);     
  });
  </code></pre>