Detect Server Down

I am wondering if a TCP/IP socket library function exists that will
automatically detect (via a signal or something similar) when a server
that is connected to a device closes its port. I am trying to avoid
using a timer proxy that at pre-defined intervals will call a function
to confirm that a connection still exists.

Thank you in advance for your response.

Dan Szymanski