Skip to content

fix(net): implement SO_ERROR for connection completion - #2182

Closed
RockYou-cmd wants to merge 1 commit into
boykopovar:mainfrom
RockYou-cmd:fix/net-connect-so-error
Closed

RockYou-cmd wants to merge 1 commit into
boykopovar:mainfrom
RockYou-cmd:fix/net-connect-so-error

Conversation

@RockYou-cmd

@RockYou-cmd RockYou-cmd commented Oct 9, 2026 •

Copy link
Copy Markdown

What

sceNetGetsockopt rejects SO_ERROR, so a caller waiting for a nonblocking connection cannot query its completion result. Implement guest SO_ERROR (0x1007), translate the host socket error to guest errno, return the output size, and preserve thread errno on successful queries.

On Windows 10 build 19045.7417, Winsock returns WSAECONNREFUSED repeatedly after a failed asynchronous connection. Track the consumed completion error per native socket, serialize connect/error queries, and reset it when another connection attempt starts. Successful connections stop this tracking once getpeername confirms a peer. Established-socket and UDP errors continue to use host behaviour.

The regression covers successful and refused loopback connections, invalid query arguments, output bounds, errno preservation, receive EAGAIN, and Windows same-socket retries with concurrent readers. The pending-connect errno mapping is already provided by merged #1448 and is not reintroduced here. FreeBSD-derived guest behaviour and unverified console semantics are recorded in TechnicalDebt.

Overlap review: 456 open PR titles/bodies checked, with diffs inspected for the open libSceNet changes. #1786 extends the same host-error mapping and #1588 changes the global synchronization used by the same exports; neither implements SO_ERROR. Resolver and pool-statistics changes have since merged and are preserved in the final rebase. No dependency on an unmerged PR.

Tested

Candidate Windows validation and final rebase:

  • macOS arm64, isolated native-ABI diagnostic: current unmodified source fails the SO_ERROR query with guest EOPNOTSUPP (45); candidate passes successful connection, asynchronous refusal and read-and-clear checks. The diagnostic supplies an isolated poller-registration hook and is not a supported-platform integration build.
  • Windows 10 build 19045.7417, WinLibs GCC 15.2.0 r7, normal CMake/Ninja Release build on f145139676a48306681d3a4d5fabf83938759daf: both networking targets compiled and guest_sce_net plus guest_sce_net_connect each passed three CTest repetitions (six executions, 0 failures, 12.85 seconds). This uses the project guest ABI.
  • Final rebase onto 51f69aa2182f28ef3b91cdc20e57431d065e3e65 preserves the same SO_ERROR implementation and tests, incorporates upstream resolver/pool-statistics changes, and resolves the TechnicalDebt conflict while retaining upstream entries. The macOS isolated loopback regression passed after this rebase. Windows/Linux integration on this final base remains pending maintainer-triggered CI; the earlier Windows run is not presented as a final-head result. Upstream Build run 37919912528 is action_required with no jobs started. The conventions check passed.
  • Linux and PS5 title/hardware execution: not performed.
  • Final author commit: b7a6823f. Diff and repository conventions checks passed.

Earlier Windows validation on df16c4c256be3c44e03eb9149a6ce5f8e8a038b2, before narrowing the patch for current main:

  • Windows 10 build 19045.7417, WinLibs GCC 15.2.0 r7, Release, AMD Radeon RX 6800 XT. Normal build and library build completed. Existing guest_sce_net and new guest_sce_net_connect passed three repetitions, including Windows refusal clearing, concurrent readers and successful same-socket retry.
  • Full CTest: 402/405 passed in 240.38 seconds. agc_driver_sdwa_float_selectors, agc_driver_sdwa_ldexp_f16, and guest_system_font failed. Temporarily removing the patch and rebuilding reproduced all three failures on the same upstream revision and machine. The two graphics mismatch values were identical; the font test ended at the same point in its output. Restoring the patch and rebuilding made both networking tests pass again.
  • These full-suite results belong to the earlier revision; they are not a claim of full-suite validation on the rebased candidate. No game compatibility improvement is claimed.

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 (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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
#2142 docs/dev/TechnicalDebt.md L367
#2161 docs/dev/TechnicalDebt.md L367
#2281 docs/dev/TechnicalDebt.md L367

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: no title is shown querying SO_ERROR through sceNetGetsockopt on main, and the Winsock error tracking is a lot to carry without one. If a title needs it, please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants