How to identify a socket node js uniquely

How can I identify the connection I`m getting conn undefined error var shortid = require('shortid'); var server = net.createServer();

    var shortid = require('shortid');
    var server = net.createServer();
    server.on('connection', function(conn) {
    conn.id = shortid.generate();
    conn.on('data', function(data) {
        conn.write('ID: '+conn.id);
    });
});
server.listen(3000);

///////////////////////
//D:\chating\index.js:52
//conn.id = shortid.generate();
//^
//
//TypeError: Cannot set property 'id' of null
//at Socket.socket.on (D:\chating\index.js:52:13)
//at emitOne (events.js:96:13)
//at Socket.emit (events.js:188:7)
//at D:\chating\node_modules\socket.io\lib\socket.js:527:12
//at _combinedTickCallback (internal/process/next_tick.js:67:7)
//at process._tickCallback (internal/process/next_tick.js:98:9)