examples: Check properly if connected
examples: Check properly if connected

So far, we connect and issue an API immediately. And only after
it fails we assume we're not connected. This is just not right
as we should have checked before issuing the API whether we are
connected at all.

Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>

libvirt/libvirt-php,libvirt/libvirt-php,libvirt/libvirt-php,zippy2/libvirt-php,zippy2/libvirt-php,zippy2/libvirt-php