EDIT:
Actually, receiving SIGPIPE
is almost "normal" for network connection applications.
This is related to the complexity of network operations and their concurrency.
For example, imagine that the other side sent all it's data and closed the connection. On your machine, the socket should still read all the data from the burred (though trying to send data will raise an error)...
...Also, the event loop used by noPoll might receive a HUP
polling information (remote disconnection / hang up) and place it in the queue. At the same time, your code might still be running or it might be placed earlier in the event queue. So at the time your code is running, the connection data wasn't updated just yet.
To handle SIGPIPE
in your network application (as indicated in this question), you should either ignore the signal or handle it (if any action is required).
Normally people write in:
signal(SIGPIPE, SIG_IGN);
Another approach might use the updated sigaction
system call:
/* setup signal handling */
struct sigaction act, old, old_term, old_pipe;
sigemptyset(&act.sa_mask);
act.sa_handler = SIG_IGN;
if (sigaction(SIGPIPE, &act, &old_pipe)) {
perror("couldn't set signal handler");
exit(errno);
};
Remember to include signal.h
#include <errno.h>
#include <signal.h>
In C++ the implementation might be slightly different, but this should work for both C and C++ (or so it seems from this question).
ORIGINAL:
I'm not sure I understand your question, but if you're looking to test if the raw socket connection is okay, look into the nopoll_conn_is_ok
function.
If you're looking to handle on_close
events, than I can't help with that - I couldn't find any on_close
event handler in the noPoll manual... but I'm sure it should be there somewhere. Otherwise, maybe look into facil.io instead, which I authored for Linux/BSD environments.