macOS: sceNetConnect with a connect timeout to a bound, non-listening loopback port returns EAGAIN, not ECONNREFUSED #22317

Closed
opened 2026-11-17 11:58:56 +00:00 by Jazeupoi · 0 comments
Jazeupoi commented 2026-11-17 11:58:56 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-17T11:58:56Z.


What happens

On macOS, guest_sce_net fails with guest_sce_net check failed at line 1187, sceNet errno 35: a sceNetConnect with the connect timeout (0x1109) set to a loopback port that is bound but not listening returns EAGAIN after the timeout instead of ECONNREFUSED (61).

Title, test or build step

guest_sce_net

AnyPS5 commit

main e798a424c7 with #17425 and #11049 merged (needed for the macOS build).

System

macOS 27.0.1, Apple M4 (GPU not used by this test), Apple clang 21.0.0 (SDK 27.2), x86-64 Release build under Rosetta 2.

Steps to reproduce

ctest -R '^guest_sce_net$' --output-on-failure

It fails after the 1.5 s connect timeout.

Log

guest_sce_net check failed at line 1187, sceNet errno 35

What was checked

  • Same result every run on this Mac.

  • The check binds connect-timeout-closed to 127.0.0.1 without listening, then connects connect-timeout-refused to that address with a 1,500,000 µs connect timeout and expects ECONNREFUSED. connect_within in libSceNet/Export.cpp waits for the nonblocking connect with poll, and when poll times out the connect fails with EAGAIN.

  • XNU sends no reset for a SYN to a port that is bound but not listening; it drops it. A host program on this Mac (x86-64 under Rosetta), nonblocking connect then poll(POLLOUT, 1500):

    target poll SO_ERROR
    127.0.0.1, port bound by another socket, no listen 0 after 1501 ms 0
    127.0.0.1, port with no socket 1 at once, POLLHUP 61 (ECONNREFUSED)

    So on macOS a connect to such a port only ever times out. A blocking sceNetConnect without a timeout would wait for the host's TCP connect timeout.

  • No open PR or issue covers this. #17878 and #17879 fix other macOS socket checks and mention guest_sce_net only as a remaining failure.

  • Possible directions: on macOS, fail a connect to a local address whose port a guest socket holds without listening with ECONNREFUSED, as FreeBSD's reset would; or, if only the test's setup matters, aim the check at a port no socket holds. I haven't written either, since the first changes connect for every caller.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6444027569 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/22317). Originally posted by [Jazeupoi](https://github.com/Jazeupoi) on 2026-11-17T11:58:56Z. --- ### What happens On macOS, `guest_sce_net` fails with `guest_sce_net check failed at line 1187, sceNet errno 35`: a `sceNetConnect` with the connect timeout (`0x1109`) set to a loopback port that is bound but not listening returns `EAGAIN` after the timeout instead of `ECONNREFUSED` (61). ### Title, test or build step `guest_sce_net` ### AnyPS5 commit `main` `e798a424c7` with #17425 and #11049 merged (needed for the macOS build). ### System macOS 27.0.1, Apple M4 (GPU not used by this test), Apple clang 21.0.0 (SDK 27.2), x86-64 Release build under Rosetta 2. ### Steps to reproduce ``` ctest -R '^guest_sce_net$' --output-on-failure ``` It fails after the 1.5 s connect timeout. ### Log ``` guest_sce_net check failed at line 1187, sceNet errno 35 ``` ### What was checked - Same result every run on this Mac. - The check binds `connect-timeout-closed` to 127.0.0.1 without listening, then connects `connect-timeout-refused` to that address with a 1,500,000 µs connect timeout and expects `ECONNREFUSED`. `connect_within` in `libSceNet/Export.cpp` waits for the nonblocking connect with `poll`, and when `poll` times out the connect fails with `EAGAIN`. - XNU sends no reset for a SYN to a port that is bound but not listening; it drops it. A host program on this Mac (x86-64 under Rosetta), nonblocking `connect` then `poll(POLLOUT, 1500)`: | target | `poll` | `SO_ERROR` | | --- | --- | --- | | 127.0.0.1, port bound by another socket, no `listen` | 0 after 1501 ms | 0 | | 127.0.0.1, port with no socket | 1 at once, `POLLHUP` | 61 (`ECONNREFUSED`) | So on macOS a connect to such a port only ever times out. A blocking `sceNetConnect` without a timeout would wait for the host's TCP connect timeout. - No open PR or issue covers this. #17878 and #17879 fix other macOS socket checks and mention `guest_sce_net` only as a remaining failure. - Possible directions: on macOS, fail a connect to a local address whose port a guest socket holds without listening with `ECONNREFUSED`, as FreeBSD's reset would; or, if only the test's setup matters, aim the check at a port no socket holds. I haven't written either, since the first changes `connect` for every caller. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
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#22317
No description provided.