Hi,

I admittedly do not know alot about unix socket programming. I have been given some code that I need to fix and I am hoping someone here could point me in the right direction.

So currently I have an application that connects to a socket and performs nonblocking reads/writes on it. The problem I have is that if you disconnect the ethernet cable the program just dies.

What I know is that I need to close the socket when I detect a disconnect. After that I imagine I should periodically try to reconnect until successful.

What I don't know is how to detect the disconnect when performing a read or a write. It seems that these operations just set errno to EWOULDBLOCK and go on their merry way.

Could someone tell me how to detect disconnects on nonblocking read/write operations?

thanks