Skip to content

Commit

Permalink
Implement support for userbuffers on Wii U
Browse files Browse the repository at this point in the history
The Wii U socket implementation has limited memory available. To support larger receive buffers, application memory needs to be provided.
To make sockets use this user memory the `SO_RUSRBUF` option needs to be set on the socket.
  • Loading branch information
GaryOderNichts committed Feb 18, 2024
1 parent d3a323f commit caeaf61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/enet/enet.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ typedef enum _ENetPeerState

enum
{
#ifdef __3DS__
#if defined(__WIIU__)
ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024,
// Send buffer size is limited since it cannot use userbuffers
ENET_HOST_SEND_BUFFER_SIZE = 0x10000 - 1,
#elif defined(__3DS__)
ENET_HOST_RECEIVE_BUFFER_SIZE = 0x20000,
ENET_HOST_SEND_BUFFER_SIZE = 0x20000,
#else
Expand Down
8 changes: 8 additions & 0 deletions unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ enet_socket_create (int af, ENetSocketType type)
}
#endif

#ifdef __WIIU__
{
// Enable usage of userbuffers on Wii U
int on = 1;
setsockopt(sock, SOL_SOCKET, SO_RUSRBUF, (char *)&on, sizeof(on));
}
#endif

return sock;
}

Expand Down

0 comments on commit caeaf61

Please sign in to comment.