protected function send($s)
    {
        if (!$this->socket) {
            $this->createSocket();
        }

        if (!$this->socket) {
            return false;
        }

        $written = 0;
        while ($s != '') {
            $written = $this->write($s);
            if ($written === false) {
                throw new \Plop\Exception('Connection lost');
            }
            $s = (string) substr($s, $written);
        }
        return true;
    }