fix(libkernel): return EDESTADDRREQ for a send on an unconnected UDP socket #2694

Closed
husseinkad wants to merge 1 commit from upstream-pr/2694 into main
husseinkad commented 2026-10-10 11:07:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by husseinkad on 2026-10-10T11:07:15Z.


What

send, sendto without an address, sendmsg without a name and write on an unconnected UDP guest socket returned ENOTCONN (57) on Windows (Winsock's WSAENOTCONN) and EIO (5) on Linux, where the host's EDESTADDRREQ had no mapping. FreeBSD's sosend_dgram (sys/kern/uipc_socket.c) returns EDESTADDRREQ (39) for a datagram socket without a connected peer or address; ENOTCONN there is only for protocols with PR_CONNREQUIRED such as TCP, which is unchanged.

NativeError now maps WSAEDESTADDRREQ and EDESTADDRREQ to 39, and a new SendError(type) maps WSAENOTCONN to 39 for datagram sockets. send and sendto use it, and sendmsg and write go through them.

Tested

Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release:

  • guest_udp gains send and sendto(NULL, 0) on the unconnected sender expecting errno 39; it fails without the change. ctest -R "guest_(udp|tcp|poll|socket)": 5 of 5 pass.
  • Outside the repo: a loopback probe through the guest exports, 554 cases per build, run against main's and this branch's Udp.cpp (UDP4/UDP6 unbound/bound/connected in blocking and nonblocking mode, send/sendto/sendmsg/write, receive family, getpeername, shutdown, oversize payloads, TCP in every state, socketpairs, closed descriptors). The only differences are ENOTCONN to EDESTADDRREQ on UDP sockets with no connected peer; TCP, connected UDP, socketpair, recv*, getpeername and shutdown results are identical.
  • tools/check_conventions.py --base origin/main passes; tools/pr_overlap.py --branch reports no overlap.
  • The POSIX branch is reviewed from the diff only; Linux not run.

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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4810736207 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2694). Originally posted by [husseinkad](https://github.com/husseinkad) on 2026-10-10T11:07:15Z. --- ### What `send`, `sendto` without an address, `sendmsg` without a name and `write` on an unconnected UDP guest socket returned `ENOTCONN` (57) on Windows (Winsock's `WSAENOTCONN`) and `EIO` (5) on Linux, where the host's `EDESTADDRREQ` had no mapping. FreeBSD's `sosend_dgram` (`sys/kern/uipc_socket.c`) returns `EDESTADDRREQ` (39) for a datagram socket without a connected peer or address; `ENOTCONN` there is only for protocols with `PR_CONNREQUIRED` such as TCP, which is unchanged. `NativeError` now maps `WSAEDESTADDRREQ` and `EDESTADDRREQ` to 39, and a new `SendError(type)` maps `WSAENOTCONN` to 39 for datagram sockets. `send` and `sendto` use it, and `sendmsg` and `write` go through them. ### Tested Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release: - `guest_udp` gains `send` and `sendto(NULL, 0)` on the unconnected sender expecting errno 39; it fails without the change. `ctest -R "guest_(udp|tcp|poll|socket)"`: 5 of 5 pass. - Outside the repo: a loopback probe through the guest exports, 554 cases per build, run against `main`'s and this branch's `Udp.cpp` (UDP4/UDP6 unbound/bound/connected in blocking and nonblocking mode, send/sendto/sendmsg/write, receive family, getpeername, shutdown, oversize payloads, TCP in every state, socketpairs, closed descriptors). The only differences are `ENOTCONN` to `EDESTADDRREQ` on UDP sockets with no connected peer; TCP, connected UDP, socketpair, `recv*`, `getpeername` and `shutdown` results are identical. - `tools/check_conventions.py --base origin/main` passes; `tools/pr_overlap.py --branch` reports no overlap. - The POSIX branch is reviewed from the diff only; Linux not run. ### 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 in TechnicalDebt - [x] No notes, investigation `.md` 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] AI-assisted: yes
github-actions[bot] commented 2026-10-10 11:08:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T11:08:44Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096863718 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2694#issuecomment-6096863718). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T11:08:44Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

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!2694
No description provided.