From e56f13b1232d345c8d87d04d10e92905483e51b3 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 21 Oct 2014 14:17:52 -0400 Subject: [PATCH] Set SO_NOSIGPIPE on Darwin to stop from breaking into the debugger every time a connection closes --- limelight-common/Platform.h | 3 +++ limelight-common/PlatformSockets.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/limelight-common/Platform.h b/limelight-common/Platform.h index f4cf1a9..9a966f0 100644 --- a/limelight-common/Platform.h +++ b/limelight-common/Platform.h @@ -21,6 +21,9 @@ # endif #else # define LC_POSIX +# if defined(__APPLE__) +# define LC_DARWIN +# endif #endif #include diff --git a/limelight-common/PlatformSockets.c b/limelight-common/PlatformSockets.c index 55be75c..bc0e8bb 100644 --- a/limelight-common/PlatformSockets.c +++ b/limelight-common/PlatformSockets.c @@ -20,7 +20,14 @@ SOCKET bindUdpSocket(void) { SetLastSocketError(err); return INVALID_SOCKET; } + +#ifdef LC_DARWIN + // Disable SIGPIPE on iOS + val = 1; + setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (char* )&val, sizeof(val)); +#endif + // Set the receive buffer to 64KB by default val = 65536; setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char*) &val, sizeof(val)); @@ -31,11 +38,20 @@ SOCKET connectTcpSocket(IP_ADDRESS dstaddr, unsigned short port) { SOCKET s; struct sockaddr_in addr; int err; +#ifdef LC_DARWIN + int val; +#endif s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (s == INVALID_SOCKET) { return INVALID_SOCKET; } + +#ifdef LC_DARWIN + // Disable SIGPIPE on iOS + val = 1; + setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (char* )&val, sizeof(val)); +#endif memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET;