public function close()
    {
        if ($this->closed)
        {
            return;
        }

        $this->emit('end', [ $this ]);
        $this->loop->removeStream($this->fd);
        $this->buffer->flushListeners();
        $this->flushListeners();
        unset($this->socket);
        $this->closed = true;
    }