If I remember correctly, creating a session doesn't actually start communication with the target device, so the error value of creating the session is not telling you if the device is turned on or not.
You have to actually do a get() or something and wait for a timeout to deal with down devices.