From d841fb7bb6af054e7cc935fd07ea6608c0d90724 Mon Sep 17 00:00:00 2001 From: Lindamea1 <322051987+Lindamea1@users.noreply.github.com> Date: Sun, 18 Oct 2026 08:09:22 +0100 Subject: [PATCH] fix(libSceNet): return EOPNOTSUPP when connecting a listening socket sceNetConnect on a listening stream socket passed the call to the host, so it failed with EISCONN (0x80410138) on Linux, EINVAL on Windows, and EAFNOSUPPORT (0x8041012f) for an address of the other family. FreeBSD 11.4 soconnectat refuses any connect on a socket with SO_ACCEPTCONN with EOPNOTSUPP before the protocol looks at the address, and libkernel connect does the same since #6950. Return 0x8041012d (EOPNOTSUPP) for a listening socket once the address is converted, before the family check. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceNet/Export.cpp | 1 + core/libs/tests/GuestSceNet.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/core/libs/prx/libSceNet/Export.cpp b/core/libs/prx/libSceNet/Export.cpp index e5537bf33df9..7099ee15b235 100644 --- a/core/libs/prx/libSceNet/Export.cpp +++ b/core/libs/prx/libSceNet/Export.cpp @@ -938,6 +938,7 @@ int APS5_VABI sceNetConnect(int s, const void* addr, uint32_t addrlen) { #ifdef _WIN32 if (socket.type == NET_SOCK_STREAM) RefuseClosedLoopbackAtOnce_nid_no_patch(socket.native->value, reinterpret_cast(&native)); #endif + if (socket.listening) return fail(NET_EOPNOTSUPP); if (native.ss_family != (socket.family == NET_AF_INET ? AF_INET : AF_INET6)) return fail(NET_EAFNOSUPPORT); if (::connect(socket.native->value, reinterpret_cast(&native), native_length) == 0) { #ifdef _WIN32 diff --git a/core/libs/tests/GuestSceNet.cpp b/core/libs/tests/GuestSceNet.cpp index e5b47cdeaeb3..ec0491517542 100644 --- a/core/libs/tests/GuestSceNet.cpp +++ b/core/libs/tests/GuestSceNet.cpp @@ -1081,6 +1081,9 @@ int main() { std::uint32_t address_size = address.size(); Require(sceNetGetsockname(listener, address.data(), &address_size) == 0 && address_size == 16); Require(address[2] != 0 || address[3] != 0); + Require(Failed(sceNetConnect(listener, address.data(), address.size()), 45)); + const std::array other_family{28, 28}; + Require(Failed(sceNetConnect(listener, other_family.data(), other_family.size()), 45)); const int client = sceNetSocket(nullptr, 2, 1, 6); Require(client >= 0);