docs(debt): record what a Windows UDP socket keeps after connect(AF_UNSPEC) #8921

Merged
xXPBSXx merged 1 commit from upstream-pr/8921 into main 2026-10-24 09:28:43 +00:00
xXPBSXx commented 2026-10-21 06:13:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T06:13:57Z.


What

The connect to AF_UNSPEC entry in docs/dev/debt/libkernel.md only described Linux. It now says the same for Windows: a UDP socket bound to an explicit address keeps that host address after the association is dissolved, getsockname reports it, and a sendto to a non-loopback address from such a socket fails with ENETUNREACH (Winsock 10051), where FreeBSD 11.4's udp_disconnect() resets the local address to the wildcard address and keeps the port, so the send goes out. No code change.

Found by comparing against FreeBSD's udp_disconnect(), not from a title; no title is known that reads the local address after the association is dissolved (see the discussion on #8682, which this replaces).

Tested

Windows 10 Pro 10.0.19045, WinLibs GCC 15.2.0 r7. A plain Winsock probe (probe_8682_disconnect.cpp, attached together with its output probe_8682_output.log, 3 runs): a UDP socket connected to a loopback peer, then connect(AF_UNSPEC), then getsockname, then sendto to this machine's LAN address.

before the disconnect host getsockname after it sendto to the LAN address
bound implicitly by connect 0.0.0.0:<port> succeeds
explicitly bound to 127.0.0.1 127.0.0.1:<port> fails, WSAENETUNREACH (10051)

These rows are the host's Winsock behaviour measured directly; they are not a run of the guest connect path on main. Not measured on a console. python tools/check_conventions.py --base upstream/main passes.

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 under Silent stubs in their library's technical debt file (n/a, docs only)
  • No notes, investigation .md files or images added to the repository (probe and output posted as a comment)
  • New third-party code is a submodule built from source (n/a)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4947253946 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8921). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T06:13:57Z. --- ### What The `connect to AF_UNSPEC` entry in `docs/dev/debt/libkernel.md` only described Linux. It now says the same for Windows: a UDP socket bound to an explicit address keeps that host address after the association is dissolved, `getsockname` reports it, and a `sendto` to a non-loopback address from such a socket fails with `ENETUNREACH` (Winsock 10051), where FreeBSD 11.4's `udp_disconnect()` resets the local address to the wildcard address and keeps the port, so the send goes out. No code change. Found by comparing against FreeBSD's `udp_disconnect()`, not from a title; no title is known that reads the local address after the association is dissolved (see the discussion on #8682, which this replaces). ### Tested Windows 10 Pro 10.0.19045, WinLibs GCC 15.2.0 r7. A plain Winsock probe (`probe_8682_disconnect.cpp`, attached together with its output `probe_8682_output.log`, 3 runs): a UDP socket connected to a loopback peer, then `connect(AF_UNSPEC)`, then `getsockname`, then `sendto` to this machine's LAN address. | before the disconnect | host `getsockname` after it | `sendto` to the LAN address | |---|---|---| | bound implicitly by `connect` | `0.0.0.0:<port>` | succeeds | | explicitly bound to `127.0.0.1` | `127.0.0.1:<port>` | fails, WSAENETUNREACH (10051) | These rows are the host's Winsock behaviour measured directly; they are not a run of the guest `connect` path on `main`. Not measured on a console. `python tools/check_conventions.py --base upstream/main` passes. ### 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 (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file (n/a, docs only) - [x] No notes, investigation `.md` files or images added to the repository (probe and output posted as a comment) - [x] New third-party code is a submodule built from source (n/a) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted (Claude Code).
MarcZX10 commented 2026-10-21 06:23:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:23:52Z.

Review: APPROVED


The debt entry now distinguishes measured Windows host Winsock behavior from guest-path and console behavior, and preserves the known Linux case. The wording states the remaining evidence gap rather than treating the host probe as console behavior. Conventions and required intake checks pass; this is documentation only.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5595713615 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8921#pullrequestreview-5595713615). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T06:23:52Z. **Review:** APPROVED --- The debt entry now distinguishes measured Windows host Winsock behavior from guest-path and console behavior, and preserves the known Linux case. The wording states the remaining evidence gap rather than treating the host probe as console behavior. Conventions and required intake checks pass; this is documentation only.
harisibrar1 commented 2026-10-21 14:08:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-21T14:08:33Z.

Review: APPROVED


Checked against main and on Windows 11 (10.0.26300):

  • Disconnect in Udp.cpp:310-336 dissolves the association with a connect to a zeroed address of the socket's family on Windows and only rebinds to the wildcard (keeping the port) when getsockname then reports port 0, so a socket bound to an explicit port keeps its host address on Windows as on Linux.
  • Reproduced the host behaviour with a plain socket probe: connected to a loopback peer, then disconnected. Implicitly bound: getsockname 0.0.0.0:port and sendto to the LAN address succeeds. Bound to 127.0.0.1: getsockname stays 127.0.0.1:port and sendto to the LAN address fails with Winsock 10051. This matches the PR's table, on Windows 11 as well as the Windows 10 it was measured on.
  • SocketError.hpp:37 maps WSAENETUNREACH to 51 (ENETUNREACH), so "fails with ENETUNREACH (Winsock 10051)" is what the guest sees. check_conventions.py --base main --head pr-8921 passes.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5601043162 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8921#pullrequestreview-5601043162). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-21T14:08:33Z. **Review:** APPROVED --- Checked against main and on Windows 11 (10.0.26300): - `Disconnect` in `Udp.cpp:310-336` dissolves the association with a connect to a zeroed address of the socket's family on Windows and only rebinds to the wildcard (keeping the port) when `getsockname` then reports port 0, so a socket bound to an explicit port keeps its host address on Windows as on Linux. - Reproduced the host behaviour with a plain socket probe: connected to a loopback peer, then disconnected. Implicitly bound: `getsockname` 0.0.0.0:port and `sendto` to the LAN address succeeds. Bound to 127.0.0.1: `getsockname` stays 127.0.0.1:port and `sendto` to the LAN address fails with Winsock 10051. This matches the PR's table, on Windows 11 as well as the Windows 10 it was measured on. - `SocketError.hpp:37` maps `WSAENETUNREACH` to 51 (`ENETUNREACH`), so "fails with `ENETUNREACH` (Winsock 10051)" is what the guest sees. `check_conventions.py --base main --head pr-8921` passes. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
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!8921
No description provided.