You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
libSceNet: sceNetListen on an unbound TCP socket fails with EINVAL on Windows; FreeBSD binds the wildcard address and succeeds; fix branch ready #5339
sceNetListen on a TCP socket the guest never bound fails with EINVAL on Windows, because Winsock requires a bound socket before listen. FreeBSD 11.4 tcp_usr_listen calls in_pcbbind when the socket has no local port (inp_lport == 0), which binds the wildcard address with an ephemeral port, so the call succeeds. A server that calls listen first and then reads the port with getsockname (a common way to get a free port) works on the console and fails here.
Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/net-listen-autobind (two commits on a recent main: the change and a correction from review; libSceNet/Export.cpp and tests/GuestSceNet.cpp with CheckListenWithoutBind for IPv4 and IPv6 and CheckListenAfterRefusedConnect). sceNetListen now binds the wildcard address of the socket's family first, unless the socket was already bound or already has a local port. The first version bound unconditionally and broke a case that worked on main: after a refused TCP connect, Winsock keeps an automatic local port, the extra bind failed with WSAEINVAL, and listen returned EINVAL where main (and FreeBSD) return 0.
Checks:
The new tests fail on main (abort), and CheckListenAfterRefusedConnect fails on the first version of the branch; both pass on the final head, 6 of 6 runs; guest_sce_net and the datagram tests pass.
Probed through the guest exports against main, IPv4 and IPv6: a fresh TCP socket now listens (main EINVAL), 50 concurrent listeners each got a distinct nonzero ephemeral port, and connect and accept to the auto-bound port work. Matches FreeBSD: a second listen returns 0, listen on a UDP socket returns EOPNOTSUPP, listen after a failed bind (EADDRNOTAVAIL or EADDRINUSE) returns 0, and backlogs 0, -1, 1, 128, INT_MAX and INT_MIN all return 0. listen on a connected or accepted socket returns EINVAL (main returned 0 or EBADF).
Closing: no title is known to reach this, and functions are only changed when a title needs them. If a title stops on or misbehaves because of it on current main, comment here with the title ID and the log line.
Activity
oneandonlydean commentedon Oct 14, 2026
Closing: no title is known to reach this, and functions are only changed when a title needs them. If a title stops on or misbehaves because of it on current main, comment here with the title ID and the log line.