We have an in-house communication system running on Tru64 unix. It employs
non-blocking TCP/IP sockets for IPC within a single host. We wish to test
the connection between a pair of processes prior to attempting to send a
message - a method called "isConnected()".
Our current implementation of isConnected() follows these steps:
1. Attempt a recv() from the target with the MSG_PEEK flag set.
2. If recv() returns a value >0 we return true.
3. If recv() returns -1 and errno is set to EWOULDBLOCK we return true.
4. Otherwise we return false.
We are frequently finding that both errno and the return value from recv()
are 0. This suggests that the connection to the target has been lost.
However, this would seem to incorrect as subsequent messages are sent
Can anyone help understand the behaviour of recv() or suggest a better way
of checking the connection.