tcp error handling question

Here’s the scenario:

I have a QNX app. running as a TCP server. A windows app connects
to it and they communicate just fine. I want to put in some error
handling, so I put in some timeouts using SO_SNDTIMEO and SO_RCVTIMEO
with the setsockopt function. During testing, if the windows machine
is powered off (power disconnected, unplugged, no normal windows
shutdown) the QNX server will get a timeout on the send or recv
function calls (depending on which it’s doing). The QNX server will
then reset itself and wait for another client, which is the desired
result. If instead the windows application closes prematurely
(crashes) but the windows machine is still up, the QNX server will
block on a send or recv function call (which ever it happens to be
doing at the time). These two functions will block indefinitely
regardless of whether or not I have the timers set or have
non-blocking turned on via ioctl. This blocking will also happen if I
just shut down the windows client normally while the QNX server is
trying to send or receive bytes. I’d like to be able to recover
gracefully from the windows machine losing power or the windows
application getting shutdown prematurely (crashing, user impatience,
whatever). If anyone has any idea why the QNX app. is hanging on the
second scenario, please let me know.

Rich Wells