Skip to content

Commit 67709b1

Browse files
committed
Merge branch 'antonholmquist-master'
2 parents f25a405 + cecfce9 commit 67709b1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

RunLoop/AsyncUdpSocket.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ - (id)initWithDelegate:(id)delegate userData:(long)userData enableIPv4:(BOOL)ena
254254
CFSocketSetSocketFlags(theSocket6, kCFSocketCloseOnInvalidate);
255255
}
256256

257+
// Prevent sendto calls from sending SIGPIPE signal when socket has been shutdown for writing.
258+
// sendto will instead let us handle errors as usual by returning -1.
259+
int noSigPipe = 1;
260+
if(theSocket4)
261+
{
262+
setsockopt(CFSocketGetNative(theSocket4), SOL_SOCKET, SO_NOSIGPIPE, &noSigPipe, sizeof(noSigPipe));
263+
}
264+
if(theSocket6)
265+
{
266+
setsockopt(CFSocketGetNative(theSocket6), SOL_SOCKET, SO_NOSIGPIPE, &noSigPipe, sizeof(noSigPipe));
267+
}
268+
257269
// Get the CFRunLoop to which the socket should be attached.
258270
theRunLoop = CFRunLoopGetCurrent();
259271

0 commit comments

Comments
 (0)