libkernel: send and sendto without a destination on an unconnected UDP socket return ENOTCONN (Windows) or EIO (Linux), where FreeBSD returns EDESTADDRREQ #3113
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by husseinkad on 2026-10-10T22:28:43Z.
What
send,sendtowithout an address,sendmsgwithout a name andwriteon an unconnected UDP guest socket (core/libs/prx/libkernel/Socket/src/Udp.cpp) returnENOTCONN(57) on Windows (Winsock'sWSAENOTCONN) andEIO(5) on Linux, where the host'sEDESTADDRREQhas no mapping inNativeError(). FreeBSD'ssosend_dgram(sys/kern/uipc_socket.c) returnsEDESTADDRREQ(39) for a datagram socket without a connected peer or address;ENOTCONNthere is only for protocols withPR_CONNREQUIREDsuch as TCP, which stays as it is (sys/sys/errno.h:EDESTADDRREQ39,ENOTCONN57). The send(2) man page lists onlyENOTCONN(for connection-mode sockets), so the source is the reference.Reproduce
Windows 11, WinLibs GCC 15.2.0 r7,
mainat the time of writing: create a UDP socket withoutconnect, callsend(sock, buf, 1, 0)orsendto(sock, buf, 1, 0, NULL, 0):-1witherrno57 (FreeBSD: 39).Fix
A tested fix is on my fork:
husseinkad:fix/net-udp-errno(one commit onmain; PR #2694, closed by the intake check):NativeError()mapsWSAEDESTADDRREQandEDESTADDRREQto 39, and a newSendError(type)mapsWSAENOTCONNto 39 for datagram sockets;sendandsendtouse it, andsendmsgandWritego through them.guest_udpgainssendandsendto(NULL, 0)on the unconnected sender and fails without the change.Checked with a loopback probe through the guest exports against
main'sUdp.cppbuilt into a secondlibkernel: 554 cases per build (UDP4/UDP6 unbound, bound and connected, blocking and nonblocking, send/sendto/sendmsg/write, the receive family,getpeername,shutdown, 70,000-byte payloads, TCP in every state, socketpairs, closed descriptors): the only differences areENOTCONNbecomingEDESTADDRREQon UDP sockets with no connected peer; TCP, connected UDP, socketpair,recv*,getpeernameandshutdownresults are identical. The Linux branch is reviewed from the diff only. Three older, separate divergences in the same send path were noted and left alone:sendtowith aNULLaddress and non-zero length returnsEINVAL, a very short address returnsEFAULT(FreeBSDEINVAL), and a send on an unconnected TCP socket on Linux returnsEPIPEinstead ofENOTCONN.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by hikazey on 2026-10-11T19:16:02Z.
Linux check, since the Linux side was reviewed from the diff only:
fix/net-udp-errno(8efd5ec7) merged ontomain06da1176, Ubuntu 24.04 container, GCC 14.2, Release with CI's configure flags.guest_udpUdp.cppreverted tomain, test keptSo the
EDESTADDRREQ→ 39 mapping does what the test expects on Linux. The three full-suite failures fail the same way on plainmainin this container and come from the setup:import_auditneedsgitinside the container, andagc_driver_flat_aperturesandagc_driver_image_packed16_loadrun on llvmpipe.One heads-up for whoever opens the PR: on current
main(a11c8f7f7)Udp.cppstill merges cleanly, butGuestUdp.cppnow conflicts afterd78af2c71andb4a59e34ctouched the socket tests.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by husseinkad on 2026-10-11T19:25:14Z.
Thank you @hikazey for the Linux run and for the heads-up about
GuestUdp.cpp. I rebased the change onto currentmain: https://github.com/husseinkad/AnyPS5/tree/fix/net-udp-errno-rebased (6c0295d3a). The conflict was in the test, which now connectssenderearlier, so the unaddressed-send checks use a fresh unconnected socket. On Windowsguest_udppasses with the change and fails withUdp.cppreverted tomain;guest_tcp,guest_socket_read_writeandguest_socket_pairpass.Note that #3592 (the socket errno table from #3573) now covers the
WSAEDESTADDRREQandEDESTADDRREQmapping inNativeError(), so after it merges the only part left here isSendError, the WindowsWSAENOTCONN→ 39 case for an unconnected datagramsend/sendto.pr_overlaplists #3592 onUdp.cppfor that reason.AI-assisted: yes