Using the SO_NOSIGPIPE socket option on macOS

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Wed May 17 12:30:29 PDT 2017


I've run into an issue using DCD [1] on macOS where it crashes with the 
exception "Unable to set socket option: Invalid argument". This occurs 
when DCD calls "accept" on the Socket it's using. Accept will, through 
some calls, eventually call "setSock", which will on macOS set the 
socket option SO_NOSIGPIPE.

It turns out that this call can fail if the remote end has closed/reset 
the socket [2]. I believe the solution is to try to reconnect. Since the 
Socket class automatically sets the SO_NOSIGPIPE option on macOS, should 
the Socket class also try to automatically reconnect or is that 
something up to the user of the Socket class to do?

[1] https://github.com/dlang-community/DCD/issues/345
[2] https://lists.apple.com/archives/macnetworkprog/2008/Jan/msg00084.html

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list