From f32fcb1c00ef5789ea92c7264638c9159303c703 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 17 Aug 2023 22:25:39 +1000 Subject: [PATCH] 3DS: Try to fix not connecting to server on real hardware --- src/Platform_3DS.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Platform_3DS.c b/src/Platform_3DS.c index 08395d51c..bb899cd78 100644 --- a/src/Platform_3DS.c +++ b/src/Platform_3DS.c @@ -34,8 +34,8 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; -const cc_result ReturnCode_SocketInProgess = EINPROGRESS; -const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; +const cc_result ReturnCode_SocketInProgess = -26; +const cc_result ReturnCode_SocketWouldBlock = -6; const cc_result ReturnCode_DirectoryExists = EEXIST; const char* Platform_AppNameSuffix = " 3DS"; @@ -380,8 +380,6 @@ static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) { int flags = mode == SOCKET_POLL_READ ? (POLLIN | POLLHUP) : POLLOUT; *success = (pfd.revents & flags) != 0; - int ret_events = pfd.revents; - Platform_Log2("POLL: %h (%h)", &ret_events, &flags); return 0; } @@ -394,9 +392,12 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) { cc_result res = Socket_Poll(s, SOCKET_POLL_WRITE, writable); if (res || *writable) return res; - /* https://stackoverflow.com/questions/29479953/so-error-value-after-successful-socket-operation */ + // Actual 3DS hardware returns EINPROGRESS if connect is still in progress + // Which is different from POSIX: + // https://stackoverflow.com/questions/29479953/so-error-value-after-successful-socket-operation getsockopt(s, SOL_SOCKET, SO_ERROR, &res, &resultSize); Platform_Log1("--write poll failed-- = %i", &res); + if (res == ReturnCode_SocketInProgess) res = 0; return res; }