diff --git a/src/Nazara/Network/Posix/SocketImpl.cpp b/src/Nazara/Network/Posix/SocketImpl.cpp index a9623e544..d76e9a34e 100644 --- a/src/Nazara/Network/Posix/SocketImpl.cpp +++ b/src/Nazara/Network/Posix/SocketImpl.cpp @@ -17,6 +17,10 @@ #include #include +#if !defined(TCP_KEEPIDLE) && defined(TCP_KEEPALIVE) +#define TCP_KEEPIDLE TCP_KEEPALIVE // see -> https://gitlab.freedesktop.org/spice/usbredir/-/issues/9 +#endi + namespace Nz { constexpr int SOCKET_ERROR = -1; @@ -597,8 +601,11 @@ namespace Nz } IpAddress senderIp; - +#if not defined(MSG_NOSIGNAL) int byteRead = recvmsg(handle, &msgHdr, MSG_NOSIGNAL); +#else + int byteRead = recvmsg(handle, &msgHdr, 0); +#endif if (byteRead == -1) { int errorCode = GetLastErrorCode(); @@ -714,7 +721,12 @@ namespace Nz msgHdr.msg_iov = sysBuffers.data(); msgHdr.msg_iovlen = static_cast(bufferCount); +#if not defined(MSG_NOSIGNAL) int byteSent = sendmsg(handle, &msgHdr, MSG_NOSIGNAL); +#else + int byteSent = sendmsg(handle, &msgHdr, 0); +#endif + if (byteSent == SOCKET_ERROR) { int errorCode = GetLastErrorCode(); @@ -896,6 +908,18 @@ namespace Nz if (error) *error = SocketError_NoError; + +#if not defined(MSG_NOSIGNAL) // -> https://github.com/intel/parameter-framework/pull/133/files + //There is no MSG_NOSIGNAL on macos + const int set = 1; + if (setsockopt(handle, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(set)) == SOCKET_ERROR) + { + if (error) + *error = TranslateErrnoToSocketError(GetLastErrorCode()); + + return false; //< Error + } +#endif return true; }