public function close() { if ($this->closed) { return; } $this->emit('end', array($this)); $this->loop->removeStream($this->fileDescriptor); $this->buffer->removeAllListeners(); $this->removeAllListeners(); unset($this->socket); $this->closed = true; }