From 5cc1ea83ca93b66816eb1ce4211bd5cbe49d21db Mon Sep 17 00:00:00 2001 From: Maximilian Fleckenstein <166870690+maximilianfv@users.noreply.github.com> Date: Sat, 24 Oct 2026 05:00:03 -0300 Subject: [PATCH] fix(libkernel): count a dissolved datagram association as disconnected on macOS On macOS, connect to AF_UNSPEC on a connected datagram socket dissolves the association but returns -1, with EAFNOSUPPORT for IPv4 and EINVAL for IPv6. Disconnect took that as a failure, so connect to port 0 on a connected datagram socket failed with 47 instead of EADDRNOTAVAIL (49). Treat the call as successful when the socket is no longer connected. Co-authored-by: marion909 <103169397+marion909@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libkernel/Socket/src/Udp.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/libs/prx/libkernel/Socket/src/Udp.cpp b/core/libs/prx/libkernel/Socket/src/Udp.cpp index 106a7501bce..d431317f440 100644 --- a/core/libs/prx/libkernel/Socket/src/Udp.cpp +++ b/core/libs/prx/libkernel/Socket/src/Udp.cpp @@ -339,6 +339,14 @@ int Disconnect(const Socket& socket) { sockaddr_storage unspecified{}; unspecified.ss_family = local.ss_family; if (::connect(socket.value, reinterpret_cast(&unspecified), localSize) != 0) return Fail(NativeError()); +#elif defined(__APPLE__) + sockaddr unspecified{}; + unspecified.sa_family = AF_UNSPEC; + if (::connect(socket.value, &unspecified, sizeof(unspecified)) != 0) { + const int error = NativeError(); + peerSize = sizeof(peer); + if (::getpeername(socket.value, reinterpret_cast(&peer), &peerSize) == 0 || errno != ENOTCONN) return Fail(error); + } #else sockaddr unspecified{}; unspecified.sa_family = AF_UNSPEC;