Linux sockets are able to throw a SIGPIPE


#1

I'm still in the process of porting one of my applications to Linux!

A socket on Linux is capable of signalling a SIGPIPE when the connection on the other end closes.  Of course, catching a signal and recovering is a decidedly non-trivial thing... so there's a Unix system call setsockoption where you can set the socket to be SO_NOSIGPIPE.

And this code exists in JUCE - except that it's commented out unless you're a Mac:  in juce_linux_Network.cpp:233, I see:

      #if JUCE_MAC
        setsockopt (socketHandle, SOL_SOCKET, SO_NOSIGPIPE, 0, 0);
      #endif

Of course, if I remove the guard this won't compile under Linux.  But we're not seeing any sort of error on any other platform...

Any ideas?


#2

All right, I did some more debugging.

I'm actually successfully opening the StreamingSocket, and reading from it - the SIGPIPE occurs when I try to write to the socket, which is definitely still open on the other end.

This same code definitely works on OS/X and almost certainly on Debian and Windows (I say, "Almost certainly" because I haven't made a build on either of them in the last few weeks, but I had bidirectional socket connections working on them for a long time).

Any thoughts greatly appreciated!