[feature] Do not use SIGPIPE with sockets. Slight improvements in debug messages.

When trying to write to a closed socket, the program used to crash silently because of SIGPIPE. By disabling the signal on write error we avoid that.

Added the debug messages required to print the error and exit the program. Slight improvements in a couple other debug messages (using strerror(errval) )