if you try to send() (or sendto()) on a unix/linux socket that has been closed from the remote side, your application will get a SIGPIPE. if you do not explicitly handle a SIGPIPE, your application will exit, and you may see ‘Broken Pipe’ printed to STDERR.
You can add code to handle (read: ignore) a SIGPIPE as follows:
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
perror("sigpipe error");
exit(0);
}
Now, when you send() (or sendto()) on a socket that has been remotely closed you should get a -1 return, with errno set to 32 (EPIPE).