Node.js net disconnection not detecting issue

I am new to node.js . In my program , following codes using for client close detection

var server = net.createServer(function (stream) {
stream.setEncoding('utf8');

stream.on('data', function (data) { 

if (data == '<policy-file-request/>\0') {
    var x = policy();
    stream.write(x);
    var server_date = new Date();
    var serv_sec = server_date.getSeconds();

    return;
} 

  });

 stream.on('error', function () {

}); 

 stream.on('close', function () 
 {

 });

when application closing , this ‘close’ function is working properly , whenever net disconnecting , that is not detecting by node.js

this ought to be on stackoverflow.com nodejs