How to handle all possible errors on async socket?

view full story

http://stackoverflow.com – I have decided to use async io for my project and simply do a single threaded loop where I try to read some data each frame from each open socket. This worked quite well and overall I'm happy with it for now. The problem is weird problems I'm having with the async sockets. I have code like this: accept a connection... fcntl(O_NONBLOCK) on the client socket... int rc; if((rc = recv(socket))>0) process data if rc == 0 close socket and cleanup The problem is that I get rc == 0 sometimes even though I know that the connection is not closed. If I don't clean up then my app works as no (HowTos)