libkernel: host socket errors outside a 17-entry table all become EIO (WSAEALREADY, WSAENOPROTOOPT, WSAEBADF, WSAEMFILE and more); fix branch ready #3573
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by husseinkad on 2026-10-11T13:35:14Z.
NativeError()inSocket/src/Udp.cppmaps only 17 host socket errors to FreeBSD numbers and returnsEIO(5) for the rest, so a guest that testserrnogets the wrong value for many real failures.Examples on Windows (before -> FreeBSD 11 number):
WSAEALREADY5 -> 37,WSAENOPROTOOPT5 -> 42,WSAEBADF5 -> 9,WSAEFAULT5 -> 14,WSAEMFILE5 -> 24,WSAEINPROGRESS5 -> 36,WSAENOTSOCK5 -> 38,WSAEDESTADDRREQ5 -> 39,WSAEOPNOTSUPP5 -> 45,WSAEAFNOSUPPORT5 -> 47,WSAENETDOWN5 -> 50. Linux has the same gaps (EPERM,ENOMEM,ENFILE,EPROTO,ESHUTDOWN,EALREADY,EINPROGRESSand others all becomeEIO).Fix branch: https://github.com/husseinkad/AnyPS5/tree/fix/kernel-socket-errno-table
GuestSockets::GuestErrorFromHostinSocket/include/SocketError.hpp: a by-name table of 70 host errors to the FreeBSD 11.4errno.hnumbers; a host error with no FreeBSD socket counterpart staysEIO.WSAESHUTDOWNstaysEPIPE, as before.Udp.cppuses it;PairError()goes away because its one special case (WSAEMFILE) is now in the table.tests/GuestSocketError.cppchecks every entry by name; deleting or renumbering any singlecasefails it (70 of 70 mutants caught on Windows).Checked against: FreeBSD 11.4
sys/sys/errno.h, the MinGWwinsock2.h/winerror.hnames, and Linux 6.6errno-base.h/errno.h. Old vs new on 13,001 Windows values and 4,201 Linux values: 18 (Windows) and 23 (Linux) inputs change, allEIObecoming the correct number, nothing else moves. 95 loopback scenarios through the guest exports on old and new builds differ in two lines only (below).guest_(socket|udp|tcp|poll|dup)pass;check_conventions.pyandpr_overlap.pyare clean.Behaviour changes worth knowing:
connectto a refused port now reportsEALREADYwhere it used to reportEIO. FreeBSD reportsECONNREFUSED; Windows never surfaces the refusal here (SO_ERRORis unsupported). A guest looping onEALREADYkeeps looping. Recorded in TechnicalDebt.setsockopt(SOL_SOCKET, SO_BROADCAST)on a TCP socket goes fromEIOtoENOPROTOOPT(FreeBSD succeeds).Not fixed here: #3113 stays half open. On Windows
send/writeon an unconnected UDP socket still returnsENOTCONNbecause Winsock reportsWSAENOTCONN, so the newWSAEDESTADDRREQentry is never reached. A receive aftershutdown(SHUT_RD)returnsEPIPEon Windows where FreeBSD returns 0.libSceNet/Export.cpphas its ownnative_error()table that this does not touch. The numbers are not checked on a console.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:55:40Z.
I carried Hussein Kadhim's two commits into PR #3592, preserving the original commit authorship. The PR adds the host-to-FreeBSD socket errno mapping and its cross-platform table test. The Linux
libkernelbuild and eight focused socket CTests pass locally; hosted checks are now running. The documented host-versus-console differences remain recorded in TechnicalDebt.Imported from boykopovar/AnyPS5. Originally posted by husseinkad on 2026-10-11T18:39:19Z.
Thank you @MarcZX100 for carrying this into #3592 with the authorship kept. Nothing to add to the caveats already listed in the issue.
AI-assisted: yes