Commit Graph

43 Commits

Author SHA1 Message Date
Dean 49b6b6a5c8
Merge pull request #4092 from yunusshaikh7/fix/libscenet-datagram-receive-timeout
fix(libSceNet): report EAGAIN when a datagram receive times out on Windows
2026-10-12 21:39:40 +13:00
Dean 98c07d8e77
Merge pull request #4111 from jdmagic/fix/kernel-close-net-sockets
fix(libkernel): close() and setsockopt() reach libSceNet sockets
2026-10-12 20:28:00 +13:00
Dean 2c51fdfba9
Merge pull request #4112 from jdmagic/fix/net-errors-set-kernel-errno
fix(libSceNet): failures also set libkernel's errno
2026-10-12 20:25:23 +13:00
Dean 4303f39b92
Merge pull request #4110 from jdmagic/fix/net-epoll-control-ops
fix(libSceNet): sceNetEpollControl takes 2 as MOD and 3 as DEL
2026-10-12 20:25:02 +13:00
Dean 01e5f3b8a8
Merge pull request #3977 from hansjm10/fix/libscenet-sockaddr-len
fix(libSceNet): accept guest socket addresses whatever their sa_len
2026-10-12 16:08:32 +13:00
jdmagic d5805fb3e4 fix(libkernel): setsockopt sets options of libSceNet sockets
A title creating a socket with sceNetSocket sets its options with the BSD
setsockopt, which looked the descriptor up only among libkernel's own
sockets and returned EBADF. libSceNet now registers an option setter with
libkernel, as it does for close and select, and accepts SO_REUSEADDR,
SO_BROADCAST, SO_SNDBUF and SO_RCVBUF like libkernel's own sockets.

PPSA01289 (Sackboy: A Big Adventure) sets SO_BROADCAST on its UDP P2P
socket this way in UIpNetDriver::InitBase. The failure made every listen
fail, and the engine travelled back to its default map with ?closed,
reloading it about every two seconds behind the loading screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 19:23:24 -04:00
jdmagic 5d14cd02ff fix(libSceNet): failures also set libkernel's errno
libSceNet stored its errno only in its own slot (sceNetErrnoLoc). Titles
that use the BSD socket model read errno after a libSceNet call, as the
console's libSceNet calls are kernel calls that set it; shadPS4 mirrors its
net errno into the kernel errno the same way (SetKernelErrnoHook).

PPSA01289 (Sackboy: A Big Adventure) reads errno through Unreal's
GetLastErrorCode after sceNetRecvfrom. It never saw EWOULDBLOCK, so
UIpNetDriver::TickDispatch kept receiving and the game thread never left
its first networked frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 19:23:24 -04:00
jdmagic 12b18af550 fix(libkernel): close() closes libSceNet sockets
A libSceNet socket is a kernel descriptor on the console, so titles close it
with close(). libSceNet keeps its sockets in its own table, and libkernel's
close passed their numbers to the CRT, which reported an invalid parameter
and left the socket open. libSceNet now registers a closer with libkernel,
as it registers its poller for select. PPSA01289 (Sackboy: A Big Adventure)
closes its P2P socket this way each time it tears its network session down,
leaking one open socket per attempt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 19:23:24 -04:00
jdmagic 22827bf6ad fix(libSceNet): sceNetEpollControl takes 2 as MOD and 3 as DEL
sceNetEpollControl used Linux's EPOLL_CTL numbering (1 ADD, 2 DEL, 3 MOD).
The SCE values are 1 ADD, 2 MOD, 3 DEL (shadPS4 net_types.h,
ORBIS_NET_EPOLL_CTL_*). A title removing a socket with op 3 and a null
event got EINVAL, and op 2 deleted the registration it meant to modify.
PPSA01289 (Sackboy: A Big Adventure) removes its UDP socket from its epoll
this way before closing it, every time its network session is torn down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 19:23:23 -04:00
Yunus Shaikh f7a85491ef fix(libSceNet): report EAGAIN when a datagram receive times out on Windows
With SO_RCVTIMEO set, Winsock fails a receive that waits that long with
WSAETIMEDOUT, which native_error turned into ETIMEDOUT (60). sceNetRecv,
sceNetRecvfrom and sceNetRecvmsg on a datagram socket therefore failed
with 0x8041013C on Windows, where FreeBSD's sbwait returns EWOULDBLOCK
(35) to soreceive, Linux returns EAGAIN, and POSIX (XSH 2.10.16)
requires EAGAIN or EWOULDBLOCK when no data was received.

A datagram socket has no connection that can time out, so WSAETIMEDOUT
there only means that the receive timeout the guest set has expired:
report EAGAIN. Stream sockets keep ETIMEDOUT, since Winsock leaves a
connection in an indeterminate state after a timeout; TechnicalDebt
records that gap and the one for SO_SNDTIMEO.
2026-10-11 16:01:51 -07:00
Jordan Hans 2d3dd337ad fix(libSceNet): accept guest socket addresses whatever their sa_len 2026-10-11 20:17:41 +00:00
overlordxrz-source 4891d625af feat(libSceNet): export sce_net_in6addr_linklocal_allnodes
Co-authored-by: eliasbruno124-dev <230422461+eliasbruno124-dev@users.noreply.github.com>
2026-10-11 11:41:05 -04:00
Abdulrahman Elkordy abed1c4314 fix(libkernel): answer select on the standard descriptors
Dungeons (PPSA16064) calls select on descriptor 0 and stopped with
"select on descriptor 0 (not a libSceNet socket) not implemented".
Descriptor 0 is now never readable and descriptors 1 and 2 are always
writable, as for a console title with no input. The assumption is in
TechnicalDebt next to the termios entry for the same descriptors.

Claude-Session: https://claude.ai/code/session_012SLQbhAiexxW6TtjYToW8a
2026-10-11 13:48:29 +03:00
Abdulrahman Elkordy 1f50b91280 fix(libkernel): report /dev/urandom descriptors ready in select
select passed every descriptor it was given to the libSceNet socket poller
and aborted on any it did not know. A title that selects on its
/dev/urandom descriptor (Dungeons, PPSA16064, aborts right after opening
it) stopped with "select on descriptors that are not libSceNet sockets".
On FreeBSD the random device is always readable and writable, so these
descriptors are now answered without the poller, and a ready one makes
the socket poll return at once.

Claude-Session: https://claude.ai/code/session_012SLQbhAiexxW6TtjYToW8a
2026-10-11 13:48:29 +03:00
MarcZX100 e864e687b3 fix(libkernel): saturate oversized select timeouts 2026-10-11 09:16:59 +02:00
MarcZX100 3d79d42663 test(net): include Windows IPv6 declarations
(cherry picked from commit 811d8c6b155fbfdae5e5277f90b435e68d42ffdc)
2026-10-11 03:47:17 +00:00
MarcZX100 2c012b4fe5 test(net): skip unavailable IPv6 loopback checks
(cherry picked from commit 9f2a0062d580b399424cb417e7f2a17cd093785b)
2026-10-11 03:47:17 +00:00
Dean 9c724baad3
Merge pull request #1786 from Zurisen/fix/windows-socket-shutdown-epipe
fix(net): report EPIPE for a send after shutdown on Windows
2026-10-10 17:41:18 +13:00
Roojool a0f42946e5 fix(net): use native Windows condition waits for empty epoll 2026-10-10 02:05:23 +02:00
Zurisen 2356aba27b fix(net): report EPIPE for a send after shutdown on Windows
Winsock fails send, sendto and sendmsg on a socket shut down for writing
with WSAESHUTDOWN, which neither Windows error map handled, so libkernel
and libSceNet reported EIO. FreeBSD reports EPIPE there, and the Linux
maps already translate the host's EPIPE to 32. Map WSAESHUTDOWN to 32
in both.
2026-10-10 02:02:29 +02:00
Dean 19a0daa786
Merge pull request #2295 from parl0v/test/sce-net-reset-on-unread-close
test(net): reset the closed peer with unread data so the send fails at once
2026-10-10 10:47:13 +13:00
Josip Parlov 61684ce98f test(net): reset the closed peer with unread data so the send fails at once 2026-10-09 16:53:26 +02:00
Claude 4a2769f26d
test(net): skip only the IPv6 socket checks on a host without IPv6
On a host without IPv6, socket(AF_INET6) fails with EAFNOSUPPORT, so
guest_sce_net aborted at its first IPv6 socket and never ran the TCP,
UDP, epoll, sendmsg/recvmsg, resolver and NetCtl checks after it.

When sceNetSocket reports guest EAFNOSUPPORT (47) for the IPv6 socket,
skip those socket checks, run the rest of the test, and exit with 77,
which ctest reports as skipped. Hosts with IPv6 run every check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
2026-10-09 10:30:28 +00:00
Obi Newman 881fb01069
feat(libs): report Http2, Ssl and Net memory pool statistics (#1119)
sceHttp2GetMemoryPoolStats, sceSslGetMemoryPoolStats and
sceNetGetMemoryPoolStats threw. PPSA16064 (Minecraft Dungeons II,
Unreal Engine) queries all three while its HTTP module starts, and
aborted there.

Each library now records the pool size given at sceHttp2Init,
sceSslInit or sceNetPoolCreate and reports it with a peak and current
use of 0: the offline Http2 and Ssl models and the host-socket Net
library allocate nothing from these pools. The layouts follow the PS4
SDK's *MemoryPoolStats structures. Net returns EBADF for an unknown
pool and EINVAL for a null output, like its other pool calls; Http2 and
Ssl throw for both, as their error codes are unknown. Terminating a
context or destroying a pool forgets its size.

sceHttp2SetResolveRetry, which the title calls next, accepts and
ignores its value like the other Http2 settings. The four Http2
WebSocket exports the title imports are added as unimplemented.

guest_http2, guest_ssl and guest_sce_net check the reported sizes;
guest_sce_net also checks the null-output and unknown-pool errors.
2026-10-09 21:03:06 +13:00
LeandroLP23 f054374661 test(libSceNet): pin the resolver info layout and check the buffer on errors
The layout offsets the titles read are static_asserts, and guest_sce_net now
checks a canary past byte 384, distinct records, and an untouched buffer on the
EINVAL, RESOLVER_ENODNS and EBADF paths, as #1845's test did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 23:58:18 +02:00
LeandroLP23 427fd92591 feat(libSceNet): implement sceNetResolverStartNtoaMultipleRecordsEx
PS5VR (PPSA99177) stops at start-up on the unresolved import sT4nBQKUPqM;
Jelly5, Emby5 and Nuvio import it too. The call fills the 384-byte resolver
info with up to ten IPv4 records (32 bytes each, family at +16) and the record
counts at +320 and +324, from the same host lookup sceNetResolverStartNtoa
uses, now shared. Only flags 0 is implemented; other flags throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 23:52:02 +02:00
Adrià f2f7abab71
Merge pull request #1448 from ewraj/fix/net-connect-einprogress
fix(libSceNet): report EINPROGRESS for a non-blocking connect and translate the missing socket errors
2026-10-08 16:02:31 +02:00
Dean f100d1d67a
Merge pull request #1373 from gjonn/feat/kernel-select-net-sockets
feat(libkernel): implement select over libSceNet sockets
2026-10-08 22:36:09 +13:00
Raj d3900b240f fix(libSceNet): translate EHOSTUNREACH and the socket errors libkernel translates
The host's EHOSTUNREACH was reported as ENETUNREACH (51); FreeBSD's
EHOSTUNREACH is 65, which libkernel's sockets already report. EADDRNOTAVAIL,
ENOBUFS, EISCONN, ENOTCONN and EACCES had no translation and became EIO;
they now map to 49, 55, 56, 57 and 13, as in libkernel/Socket/src/Udp.cpp.

guest_sce_net connects the connected client again and expects EISCONN
(0x80410138); before this change it received EIO.
2026-10-08 12:23:36 +05:30
Raj 513479380c fix(libSceNet): report EINPROGRESS for a non-blocking connect
A non-blocking sceNetConnect that cannot complete at once must fail with
EINPROGRESS (36, 0x80410124), as FreeBSD's connect does, and a repeated call
while it is pending with EALREADY (37). On Windows, Winsock reports the
first case as WSAEWOULDBLOCK, which was translated to EAGAIN (0x80410123); on
Linux, EINPROGRESS and EALREADY had no translation and became EIO
(0x80410105). Code that waits for the connection only when connect reports
EINPROGRESS treated both as a failed connection.

guest_sce_net connects a non-blocking socket to the loopback listener and
accepts 0 or EINPROGRESS; before this change it received EAGAIN on Windows.
2026-10-08 12:22:49 +05:30
Dean c8a2f06325
Merge pull request #1248 from eliasbruno124-dev/fix/net-ipv6-any-current
fix(net): provide IPv6 unspecified address object
2026-10-08 18:29:31 +13:00
Gjon Gojcevic a47fe27d28 feat(libkernel): implement select over libSceNet sockets
libSceNet registers a socket poller with libkernel; select polls the requested descriptors through it until the timeout and rewrites the descriptor sets.
2026-10-07 20:47:03 -04:00
eliasbruno124-dev 971099aa15 fix(net): provide IPv6 unspecified address object 2026-10-07 22:11:33 +02:00
kjhq 63af67138f feat(libSceNet): export in6addr_any and in6addr_loopback
libSceNet exports the IPv6 wildcard and loopback addresses as data.
2026-10-07 10:43:24 +00:00
Adrià Franch 92d79996c7 libSceNet: implement sceNetSendmsg and sceNetRecvmsg
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-06 11:51:42 +02:00
Dean 901ddfd1f8
Merge pull request #783 from adriadam10/feat/net-resolver-get-error
feat(libSceNet): implement sceNetResolverGetError
2026-10-06 14:14:10 +13:00
Dean 9cafa33f94
Merge pull request #658 from NumberGuan/codex/fix-net-inet-ntop-errors
fix(net): report address text buffer errors to the guest
2026-10-06 13:29:03 +13:00
Adrià Franch 9fb83a2435 feat(libSceNet): implement sceNetResolverGetError
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-06 01:40:36 +02:00
Dean 6eebd23a62
Merge pull request #745 from Blizzeq/fix/net-error-codes
fix(net): return SCE_NET_ERROR codes from failing sceNet calls
2026-10-06 12:24:24 +13:00
Jakub Krasuski f91e13447d fix(net): return SCE_NET_ERROR codes from failing sceNet calls
Every failing sceNet function returned -1 and left the code only in
sceNetErrnoLoc. The functions return the errno combined with
0x80410100 (SCE_NET_ERROR_*), as the resolver paths of this file
already do with RESOLVER_ENODNS and as shadPS4 and fpPS4 do for the
whole library. A title that compares the result with
SCE_NET_ERROR_EWOULDBLOCK saw a non-blocking receive without data as
an unknown failure.

Assisted-by: Claude Opus 5.5
2026-10-05 21:58:21 +02:00
Jakub Krasuski 01220faa1a fix(net): keep SIGPIPE from killing the process on Linux sends
sceNetSend and sceNetSendto called send and sendto without
MSG_NOSIGNAL, so a send on a connection the peer had closed raised
SIGPIPE and terminated the process. shadPS4 has sceNetSend pass
0x20000, FreeBSD's MSG_NOSIGNAL, down to sendto, so a title gets the
error back instead of a signal.

Pass MSG_NOSIGNAL on Linux and translate EPIPE, which fell through to
EIO.

Assisted-by: Claude Opus 5.5
2026-10-05 21:57:20 +02:00
Tomás Ortellado 77dc9e77e1 fix(net): report address text buffer errors to the guest 2026-10-05 09:01:14 -03:00
Praetorian0420 e3eeac4a81 Implement network control and socket functionality improvements
- Enhanced the network control library to check for host addresses and update connection states accordingly.
- Added support for socket operations including connect, listen, accept, send, and recv in the UDP and TCP socket implementations.
- Introduced error handling for various socket operations, ensuring proper feedback for unsupported actions.
- Created comprehensive tests for both TCP and UDP socket functionalities, validating the expected behavior of the network stack.
- Refactored existing code to improve clarity and maintainability, including the removal of unused functions and the addition of necessary error checks.
2026-09-30 23:29:01 -05:00