SIGPIPE is useless for TCP. This signal was invented for shell pipes (e.g.
proc_1 | proc_2 | proc_3), because
SIGINT is only delivered to the last process in the shell pipe. When the last process is killed and the previous process tries to write into its
stdout it gets killed with
SIGPIPE because the reader of the pipe terminated and so on, effectively killing all processes involved in the shell pipe. And this is why the signal has word pipe in its name.
Normally people ignore
SIGPIPE completely when doing TCP:
// Early in main().
ssize_t rc = send(..., MSG_NOSIGNAL);
if(rc == -1)
// errno can be EPIPE
This way your just deal with error from
errno is set to
SIGPIPE is ignored it is not necessary to use
MSG_NOSIGNAL, but it is still good practice, IMO.