protected function write($line)
    {
        for ($written = 0, $len = strlen($line); $written < $len; $written += $fwrite) {
            $fwrite = fwrite($this->socket, substr($line, $written));
            if ($fwrite === false) {
                throw new \Erebot\Exception('Connection closed by proxy');
            }
        }
        return $written;
    }