public function close(\Exception $error = null) { if (!$this->readable) { return; } $this->readable = false; $this->emit('end', array($error, $this)); $this->removeAllListeners(); $this->stream->close(); }