node.js / Socket.timeout(number)

I wrote the next code:

socket.setTimeout(2000);
socket.on('timeout', function() {   
    console.log("Timeout");
});
    socket.on('data', function(data){})

I send a data to my socket, but when I finish to send this data, the timeout doesn't occuer.

There is no socket.end() in my code.

The easiest way is to pass the timeout callback as a method straight to setTimeout where it will be added as a one-time listener to 'timeout';

socket.setTimeout(2000, function() {  
    console.log("Timeout");
});
socket.on('data', function(data){})

I've never seen the syntax of listening to the '' event before (I probably missed something), but the event for a timeout if you want to listen with it using on should be called 'timeout'.