on 'end', call socket.end(). the 'close' event should be triggered
afterwards