sockets: support Mac OS X way of disabling SIGPIPE on a socket

Mac OS X doesn't have MSG_NOSIGNAL, so we need to use SO_NOSIGPIPE.