I have a cross-platform code that I wrote at the socket level on Linux and iPhone. It opens non-blocking sockets and connects to the server. Everything works fine, except when one of the clients / servers shuts down, it stops exec via SIGPIPE, and the other during a recv or send call.
It makes sense. On Linux, I can use the flag to tell the lib OS not to raise SIGPIPE - then I can feel the error myself and process it cleanly. It works great
However, on the iPhone OS (and, presumably, osx, which I care about later) there is no flag indicating not to drop SIGPIPE. I can make a signal (SIGPIPE, IGN); which seems to be USUALLY stopping it, but still sometimes I get it ??? (This may be due to the fact that I set up the processing of this signal - can I do this only when the application starts, and I may have to do this every time the application becomes active?)
All this makes me feel like I am breaking the gap in the wrong way - should I use select () or friends to figure out if a disconnect has occurred? In particular, how can I do this?
source
share