how to get socket.id of a connection on client side? : <p>Im using the following code in index.js</p>

<pre><code>io.on('connection', function(socket){
console.log('a user connected');
console.log(socket.id);
});
</code></pre>

<p>the above code lets me print the socket.id in console.</p>

<p>But when i try to print the socket.id on client side using the following code</p>

<pre><code>&lt;script&gt;
var socket = io();
var id = socket.io.engine.id;
document.write(id);
&lt;/script&gt;
</code></pre>

<p>it gives 'null' as output in the browser.</p>
