mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 08:55:48 +00:00
Set SO_NOSIGPIPE on Darwin to stop from breaking into the debugger every time a connection closes
This commit is contained in:
parent
affcb84d36
commit
e56f13b123
@ -21,6 +21,9 @@
|
||||
# endif
|
||||
#else
|
||||
# define LC_POSIX
|
||||
# if defined(__APPLE__)
|
||||
# define LC_DARWIN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user