TCP socket, detecting host absence

Is there an effective method of detecting that a machine you are connected to unexpectedly disappears off the network?

In testing, I can “disappear” a machine and the TCPSocket still thinks it’s connected and no error/disconnect event fires…

Edit: I also just discovered that I can send to the device and the send progress and complete events fire… how is this even possible? I’m sending to a Windows virtual machine that I’m pausing or suspending. If I try to connect to the machine when it’s paused (using other code), it fails. Implying to me that I “disappeared” it successfully.

ping ?

I would go for a “keep alive” message every x seconds after the last packet been send/received, to prevent the connection being dropped by load balancing gear when idle and you will be for sure be aware about the real status of the connection.

[quote=278325:@Steve Upton]Is there an effective method of detecting that a machine you are connected to unexpectedly disappears off the network?
[/quote]
Send something to it and see if you get an error
Thats really the only way

ok. thanks all.

Norman, I think I came to about the same conclusion. I sent some data and received an eventual “no route to host” error.

I was hoping for something a bit more event-driven and self aware from the socket but this will do

thanks