feat(libSceRudp): bind, listen and accept as a firmware 13.42 run shows #13799
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13799"
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 zaryabzip on 2026-10-31T07:14:48Z.
What
sceRudpBind,sceRudpSetEventHandler,sceRudpListenandsceRudpAcceptfollow @BunnyFl's firmware 13.42 runs of the real exports (first, socket records), done under an emulator with imports stubbed, not on a console. This is theBindfollow-up that #13718 mentions; #13718 has merged, so every commit here is new.sceRudpBind(int ctxId, int socketId, uint16_t vport, uint8_t muxMode)0x80770001; negative id or socket0x80770004; mux mode other than 1 or 20x80770006; unknown or terminated id0x80770003; listening0x80770011; second bind0x8077001D; a mux mode other than that of the contexts on the socket0x80770006; mux mode 1 with vport 00x80770015; with mux mode 2, a vport in use on the socket0x80770017sceRudpSetEventHandler(handler, arg)0x80770022sceRudpEndclears itsceRudpListen(int ctxId, int backlog)0x80770004; no handler0x80770022; unknown id; not bound with mux mode 20x80770011; second listen0x80770021sceRudpAccept(ctxId, handler, arg, int* newCtxId, addr, addrLen, vport)newCtxId0x80770004; unknown id; not listening0x807700110x80770016(WOULDBLOCK) while option 7 is set, as by default; otherwise it waits untilsceRudpTerminateends the context and returns0x80770014, as the run didmaindeclaredBindas(ctxId, vport, transport, port), which the run shows is wrong, andListenandAcceptwithout parameters. The second run settled the socket records:sceRudpTerminate: a bound context that isn't listening frees its vport, and the record if it was the last, before returning. A listening context's id is gone at once, but its vport and the record are held until the nextsceRudpProcessEvents, which now releases them.Two cases still throw
std::runtime_error, as the library does for its other narrow unmeasured cases:0x80770018when none is free, but that wasn't run;sceRudpEnd.The test pins neither. When a socket's record goes, the module's next
sceRudpProcessEventscalls thesceRudpSetEventHandlerhandler with(2, socketId, 0, 0, 0, 0, arg). That handler is typed here as the four-argument context handler, so the call isn't made; the newsceRudpTerminatedebt entry records it with the rest of what isn't modelled.sceRudpGetLocalInfostays throwing: on a bound context the console copies the address fromsceNetGetsockname, which this library doesn't reach. libSceRudp goes from 31 to 33 of 35.The new
GuestRudpListen.cppcovers each measured check in order beforesceRudpInit, on bound, listening, unbound and mux mode 1 contexts, aftersceRudpTerminateand aftersceRudpEnd. That includes the rows the second run gave for the order: a bound context answers0x8077001Dto arguments that fail a socket check, a listening one0x80770011, and mux mode 1 with vport 0 on a mux mode 2 socket0x80770006. It also covers:sceRudpProcessEvents(0)and free after it;sceRudpTerminatefrom another thread.It resolves
ListenandAcceptat runtime through function types that match the new declarations, so it builds onmainand aborts there at its first check.GuestRudpContextLifecycle.cppchanges three lines:SetEventHandlerbefore init now returnsNOT_INITIALIZED, and its two binds after initialization use mux mode 2, because mux mode 0 is rejected.Overlap, rechecked with
git merge-treeagainstmain73f4f7e06eand every open pull request that merges with it:sceRudpActivateblock inGuestRudpContextLifecycle.cppright above thesceRudpBind(ctx, 0, 0, 0)line that this changes, so whichever merges second needs a one-line rebase.sceRudpEndnext to the lines this adds there, and both add a debt entry at the same place. I'll rebase whichever of the two merges second.Tested
Windows 11 (WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2) and Ubuntu 24.04 on WSL2 (GCC 13.3.0, CMake 3.28.3, Ninja 1.11.1).
651808a48bmerged intomain73f4f7e06e:libSceRudp/include/Api.hpprebuilds with no warnings, and so does each header compiled on its own.ctest -R "guest_rudp|rudp_poll": 8 of 8 pass on WSL2 and 9 of 9 on Windows (plusrudp_poll_wait_exception).guest_offline_importspasses, andguest_rudp_listenpasses 3 of 3 on--repeat until-fail:3.9c423e59bdwith only the newGuestRudpListen.cppaborts on both hosts withsceRudpBind: a bind failing more than one socket check, the throw this replaces (Windows exit 0xc0000409, Linux SIGABRT).sceRudpTerminatefreeing a listening context at once:a listening context's vport was freed before sceRudpProcessEvents.vport 0 did not skip a vport bound by hand.a listening context did not answer NOT_ACCEPTABLE to a bind.a bind expected to succeed failed.maincommits: on thatmainwith only the new test file and itsCMakeLists.txtblock, the test builds and then aborts at its first check,a handler was set before sceRudpInit, on both hosts.tools/check_conventions.pypasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)