fix(libSceNet): auto-bind an unbound stream socket on listen #5349

Closed
MarcZX10 wants to merge 3 commits from upstream-pr/5349 into main
MarcZX10 commented 2026-10-13 17:39:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T17:39:01Z.


What

On Windows, Winsock requires a stream socket to be bound before listen, while FreeBSD implicitly binds an unbound socket to a wildcard address and ephemeral port. Bind an unbound IPv4 or IPv6 socket before listening, and skip that bind when a failed connect has already assigned a local port.

Adds IPv4/IPv6 listen-without-bind coverage, including connect/accept/data exchange, and a regression case for listening after a refused connection. Carries Hussein Kadhim's ready fix branch; its two implementation commits retain his authorship. The final commit moves the test helpers to avoid conflicts with open PRs #4669 and #4988.

Tested

  • Linux x86_64, GCC 12.2, Ninja Release: built guest_sce_net_tests; ctest -R '^guest_sce_net$' passed (1/1).
  • Hussein's issue report records the new cases failing on main and passing on the final branch on Windows, with six successful runs; the Windows build and runtime checks were performed by him.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are listed in technical debt
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Closes #5339

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4847108424 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5349). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T17:39:01Z. --- ### What On Windows, Winsock requires a stream socket to be bound before `listen`, while FreeBSD implicitly binds an unbound socket to a wildcard address and ephemeral port. Bind an unbound IPv4 or IPv6 socket before listening, and skip that bind when a failed connect has already assigned a local port. Adds IPv4/IPv6 listen-without-bind coverage, including connect/accept/data exchange, and a regression case for listening after a refused connection. Carries Hussein Kadhim's ready fix branch; its two implementation commits retain his authorship. The final commit moves the test helpers to avoid conflicts with open PRs #4669 and #4988. ### Tested - Linux x86_64, GCC 12.2, Ninja Release: built `guest_sce_net_tests`; `ctest -R '^guest_sce_net$'` passed (1/1). - Hussein's issue report records the new cases failing on `main` and passing on the final branch on Windows, with six successful runs; the Windows build and runtime checks were performed by him. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; silent stubs are listed in technical debt - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes Closes #5339
github-actions[bot] commented 2026-10-13 17:48:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T17:48:22Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4785 core/libs/tests/GuestSceNet.cpp L651
#4989 core/libs/prx/libSceNet/Export.cpp L462
#5536 core/libs/tests/GuestSceNet.cpp L569
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6151668061 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5349#issuecomment-6151668061). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T17:48:22Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4785 | `core/libs/tests/GuestSceNet.cpp` [L651](https://github.com/boykopovar/AnyPS5/blob/71c71f50b7a42ad1a62b78d9cd24f5a356965557/core/libs/tests/GuestSceNet.cpp#L651) | | | | #4989 | `core/libs/prx/libSceNet/Export.cpp` [L462](https://github.com/boykopovar/AnyPS5/blob/71c71f50b7a42ad1a62b78d9cd24f5a356965557/core/libs/prx/libSceNet/Export.cpp#L462) | | | | #5536 | `core/libs/tests/GuestSceNet.cpp` [L569](https://github.com/boykopovar/AnyPS5/blob/71c71f50b7a42ad1a62b78d9cd24f5a356965557/core/libs/tests/GuestSceNet.cpp#L569) | | |
LeandroLP23 commented 2026-10-13 22:58:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-13T22:58:24Z.


Windows check, where the unbound listen fails today: Windows 11 (26300), WinLibs GCC 15.2.0, Release, head dc39e89e1 merged onto main 30f961266.

  • With the PR: guest_sce_net passes (2.5 s).
  • With main's libSceNet/Export.cpp and the PR's test: it fails. The test aborts (exit 0xc0000409), consistent with sceNetListen on an unbound TCP socket failing with EINVAL on Windows.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156982231 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5349#issuecomment-6156982231). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-13T22:58:24Z. --- Windows check, where the unbound `listen` fails today: Windows 11 (26300), WinLibs GCC 15.2.0, Release, head `dc39e89e1` merged onto `main` `30f961266`. - With the PR: `guest_sce_net` passes (2.5 s). - With `main`'s `libSceNet/Export.cpp` and the PR's test: it fails. The test aborts (exit `0xc0000409`), consistent with `sceNetListen` on an unbound TCP socket failing with `EINVAL` on Windows. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-14 02:28:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:28:25Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159535146 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5349#issuecomment-6159535146). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:28:25Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5349
No description provided.