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
This commit is contained in:
parent
681f83e51e
commit
f91e13447d
|
|
@ -49,6 +49,7 @@ constexpr int NET_ECONNABORTED = 53;
|
|||
constexpr int NET_EMSGSIZE = 40;
|
||||
constexpr int NET_ETIMEDOUT = 60;
|
||||
constexpr int NET_ECONNREFUSED = 61;
|
||||
constexpr int NET_ERROR_BASE = static_cast<int>(0x80410100u);
|
||||
constexpr int NET_ERROR_RESOLVER_ENODNS = static_cast<int>(0x804101E1u);
|
||||
|
||||
constexpr int NET_AF_INET = 2;
|
||||
|
|
@ -212,7 +213,7 @@ int* errno_slot() {
|
|||
|
||||
int fail(int err) {
|
||||
*errno_slot() = err;
|
||||
return -1;
|
||||
return NET_ERROR_BASE | err;
|
||||
}
|
||||
|
||||
void log_soft(const char* func, const char* what) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ std::int64_t APS5_VABI sceNetRecv(int, void*, std::size_t, int);
|
|||
std::int64_t APS5_VABI sceNetSendto(int, const void*, std::size_t, int, const void*, std::uint32_t);
|
||||
std::int64_t APS5_VABI sceNetRecvfrom(int, void*, std::size_t, int, void*, std::uint32_t*);
|
||||
int APS5_VABI sceNetSocketClose(int);
|
||||
int APS5_VABI sceNetSetsockopt(int, int, int, const void*, std::uint32_t);
|
||||
int* APS5_VABI sceNetErrnoLoc(void);
|
||||
int APS5_VABI sceNetEpollCreate(const char*, int);
|
||||
int APS5_VABI sceNetEpollControl(int, int, int, const NetEpollEvent*);
|
||||
int APS5_VABI sceNetEpollWait(int, NetEpollEvent*, int, int);
|
||||
|
|
@ -53,6 +55,10 @@ int main() {
|
|||
address_size = peer.size();
|
||||
const int accepted = sceNetAccept(listener, peer.data(), &address_size);
|
||||
Require(accepted >= 0 && address_size == 16);
|
||||
const int nonblocking = 1;
|
||||
Require(sceNetSetsockopt(accepted, 0xffff, 0x1200, &nonblocking, sizeof(nonblocking)) == 0);
|
||||
char pending = 0;
|
||||
Require(sceNetRecv(accepted, &pending, sizeof(pending), 0) == static_cast<int>(0x80410123) && *sceNetErrnoLoc() == 35);
|
||||
|
||||
const int epoll = sceNetEpollCreate("guest-sce-net", 0);
|
||||
Require(epoll >= 0);
|
||||
|
|
@ -73,6 +79,7 @@ int main() {
|
|||
Require(sceNetSocketClose(accepted) == 0);
|
||||
Require(sceNetSocketClose(client) == 0);
|
||||
Require(sceNetSocketClose(listener) == 0);
|
||||
Require(sceNetSocketClose(listener) == static_cast<int>(0x80410109) && *sceNetErrnoLoc() == 9);
|
||||
|
||||
const int udp_receiver = sceNetSocket(nullptr, 2, 2, 17);
|
||||
const int udp_sender = sceNetSocket(nullptr, 2, 2, 17);
|
||||
|
|
|
|||
Loading…
Reference in New Issue