lib/client/client.js
function postSetup() {
    socket.removeAllListeners('error')
      .removeAllListeners('close')
      .removeAllListeners('end')
      .removeAllListeners('timeout');

    // Work around lack of close event on tls.socket in node < 0.11
    ((socket.socket) ? socket.socket : socket).once('close',
      self._onClose.bind(self));
    socket.on('end', function onEnd() {
      if (log.trace())
        log.trace('end event');

      self.emit('end');
      socket.end();
    });
    socket.on('error', function onSocketError(err) {
      if (log.trace())
        log.trace({err: err}, 'error event: %s', new Error().stack);

      self.emit('error', err);
      socket.destroy();
    });
    socket.on('timeout', function onTimeout() {
      if (log.trace())
        log.trace('timeout event');

      self.emit('socketTimeout');
      socket.end();
    });
  }
function postSetup() {
    socket.removeAllListeners('error')
      .removeAllListeners('close')
      .removeAllListeners('end')
      .removeAllListeners('timeout');

    // Work around lack of close event on tls.socket in node < 0.11
    ((socket.socket) ? socket.socket : socket).once('close',
      self._onClose.bind(self));
    socket.on('end', function onEnd() {
      if (log.trace())
        log.trace('end event');

      self.emit('end');
      socket.end();
    });
    socket.on('error', function onSocketError(err) {
      if (log.trace())
        log.trace({err: err}, 'error event: %s', new Error().stack);

      self.emit('error', err);
      socket.destroy();
    });
    socket.on('timeout', function onTimeout() {
      if (log.trace())
        log.trace('timeout event');

      self.emit('socketTimeout');
      socket.end();
    });
  }
Wire up "official" event handlers after successful connect/setup