Fixes for Gamecube, Dreamcast, etc

This commit is contained in:
UnknownShadow200 2025-10-15 22:22:55 +11:00
parent 309c6d920f
commit a44d18f2c1
6 changed files with 26 additions and 20 deletions

View File

@ -658,12 +658,15 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
}
cc_result Socket_GetLastError(cc_socket s) {
int error = ERR_INVALID_ARGUMENT;
socklen_t errSize = sizeof(error);
//int error = ERR_INVALID_ARGUMENT;
//socklen_t errSize = sizeof(error);
/* https://stackoverflow.com/questions/29479953/so-error-value-after-successful-socket-operation */
getsockopt(s, SOL_SOCKET, SO_ERROR, &error, &errSize);
return error;
// https://github.com/KallistiOS/KallistiOS/blob/7bf0e0329b23482eae9f5231f39a0843dee407c7/kernel/net/net_tcp.c#L1493
// TODO not actually implemented
//getsockopt(s, SOL_SOCKET, SO_ERROR, &error, &errSize);
//return error;
return 0;
}

View File

@ -405,18 +405,6 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
return Socket_Poll(s, SOCKET_POLL_WRITE, writable);
}
cc_result Socket_GetLastError(cc_socket s) {
int error = ERR_INVALID_ARGUMENT;
u32 errSize = sizeof(error);
return 0;
// TODO FIX with updated devkitpro ???
/* https://stackoverflow.com/questions/29479953/so-error-value-after-successful-socket-operation */
net_getsockopt(s, SOL_SOCKET, SO_ERROR, &error, errSize);
return error;
}
static void InitSockets(void);

View File

@ -82,6 +82,15 @@ static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
*success = FD_ISSET(s, &set) != 0; return 0;
}
cc_result Socket_GetLastError(cc_socket s) {
int error = ERR_INVALID_ARGUMENT;
u32 errSize = sizeof(error);
/* https://stackoverflow.com/questions/29479953/so-error-value-after-successful-socket-operation */
net_getsockopt(s, SOL_SOCKET, SO_ERROR, &error, errSize);
return error;
}
static void InitSockets(void) {
// https://github.com/devkitPro/wii-examples/blob/master/devices/network/sockettest/source/sockettest.c
char localip[16] = {0};

View File

@ -90,6 +90,11 @@ static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
return 0;
}
cc_result Socket_GetLastError(cc_socket s) {
return 0;
// TODO Not implemented in devkitpro libogc
}
static void InitSockets(void) {
int ret = net_init();
Platform_Log1("Network setup result: %i", &ret);

View File

@ -589,7 +589,7 @@ cc_result Socket_Write(cc_socket s, const cc_uint8* data, cc_uint32 count, cc_ui
if (sentCount != -1) { *modified = sentCount; return 0; }
int ERR = GetSocketError(s);
Platform_Log1("ERR: %i", &ERR);
Platform_Log1("ERW: %i", &ERR);
*modified = 0; return ERR;
}

View File

@ -474,8 +474,9 @@ static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
struct pollfd pfd;
int flags;
pfd.fd = s;
pfd.events = mode == SOCKET_POLL_READ ? POLLIN : POLLOUT;
pfd.fd = s;
pfd.events = mode == SOCKET_POLL_READ ? POLLIN : POLLOUT;
pfd.revents = 0;
if (poll(&pfd, 1, 0) == -1) { *success = false; return errno; }
/* to match select, closed socket still counts as readable */